Miller Puckette schrieb:
Well, if in callback mode, the non-interrupt main loop is also in a different thread from the audio (if I understand correctly) and so there shouldn't be any difference between adding stuff to Pd's "main" thread and adding other threads. I think the locking considerations are the same too.
So it's probably adequate just to have the callback scheduler obtain the "global lock" and let externs add whatever they want as separate threads.
Hmmm, i guess you are right. I think however that it's a good idea to keep the number of threads accessing the PD API by using locks small. In flext there's one general helper thread (or idle callback function, depending on the PD API version) forwarding messages from threaded externals to the PD kernel (messages via senders and outlets), employing a lockfree fifo. This can also be done in PD style standard C by use of the fifo mechanism in pd-devel as implemented by Tim Blechmann.
Come to think of it, that also would remove the need for an idle() function in case one is using the polling scheduler too, no?
I think so... by the way, has anyone used the idle function as it is in standard-PD?
gr~~~