hi thomas and all,
Am Sonntag 28 August 2005 18:20 schrieb Thomas Grill:
Hi Christian,
otherwise, using threads in PD is just like using threads anywhere else. use the pthread stuff (which also works on windoze mitlerweile), and just put some mutex's around your read/write operations.
threads in PD is more difficult if you need to use PD functions therein. For that you can use sys_lock/sys_unlock (flext::Lock(), flext::Unlock()) to be sure to be the only thread, but that's sub-optimal because it may cause priority inversion (locking to real-time thread for too long a time).
thanks, but i got it mangled so far. olaf matthes told me that his object to read the old cvbox uses a thread.
however, things are much more simple here.
In flext you don't need to lock if you just want to send messages to the outlets. These and some other functions are thread-safe. The devel branch has some other very nice feature, namely idle processing via callback... in many cases this is much better than using a thread.
after all, i dont need any lock. the thread only reads the usb bus with a really high timeout value. it then fills one side of a double_buffer, while the other side is read by the metro-like tick in the ps object. if that reading buffer is empty, the thread will switch the buffers, thats all. no pd functions involved in the thread.
all the best, Thomas
thanks for the help, greets,
chris