[PD] object using a thread?
Thomas Grill
gr at grrrr.org
Sun Aug 28 18:20:12 CEST 2005
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).
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.
all the best,
Thomas
More information about the Pd-list
mailing list