We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSyntax Questions › multi-threaded processing
Page Index Toggle Pages: 1
multi-threaded processing (Read 834 times)
multi-threaded processing
Apr 2nd, 2010, 2:08pm
 
Is there any way to render or setup processing apps over multiple threads?

I use ruby-processing, and I'm quite familiar with starting new threads -- I just didn't know if processing methods were all thread-safe.  So for example as I'm setting up scenes to be rendered I could spread the loop over multiple threads.

Thanks
John-Michael

PS - googling for "multithreaded processing" in reference to the processing language itself, is a horrible idea
Re: multi-threaded processing
Reply #1 - Apr 5th, 2010, 7:35am
 
Most of the api is functionally thread-safe, but I don't think that any of it is guaranteed to be.  Notable problems are the various color value setting/getting functions, as they may use intermediate storage in the class to convert between colorspaces.  (so if those intermediates are 'clobbered' by another thread, the first thread won't get the result it expects -- i know this from experience, doh! :D)

As long as you're doing just "internal" work in your threads, then either synchronize or iterate through the individual thread containers one at a time after they've stopped for "rendering", then you'll likely be safe.  That is, I'd suggest trying to stay away from doing any unsynchronized "drawing" inside a running thread.
Re: multi-threaded processing
Reply #2 - Apr 6th, 2010, 6:34am
 
maybe this hack could be of use:
http://processing.org/hacks/hacks:registerevents
Page Index Toggle Pages: 1