1 Reply Latest reply on Dec 16, 2007 10:53 AM by Greg Dove


      I was just wandering - did anyone think of a way to make a function pause execution and continue later?

      Example: A very computation intensive function, like analyzing a huge text and cross referencing bits of it and stuff.. Which takes so long that a) the movie becomes stuck for the length of the computation, b) if it's really long, you get a warning that a script is causing this movie to run slowly etc etc..

      So I was thinking of something like the java Thread.sleep() method, that would save the local variables, stop the execution and then return after a predefined time and continue where it left..

      Since we don't have that the simplest solution would be to write the function so you could call it repeatedly and it would execute only shorter bits of calculation every frame.. but that means rewriting the function..

      So I was just wandering if anyone else thought about this and if they had any ideas? I don't really need it, I just wrote a function that needs a lot of data and it made me thinking..
        • 1. sleep
          Greg Dove Level 4
          When I need to do that I tend to use a frame-based approach and have the task broken down so that manageable 'chunks' of data get processed each call. Maybe someone's written a 'thread' type class somewhere to make it easier/more generic, but I've only needed to do it for things like processing large xml data etc and have just used ad-hoc code. I used a frame based approach because it seemed to make sense... no need to perform the activity 'chunks' slower than a single frame update and probably no benefit to do it faster than a frame update (I assumed that would only delay the frame update). So the critical thing remains the amount of processing work you assign to each 'chunk' of activity.