[PD-dev] outlet_anything() & threads

Christian Klippel ck at mamalala.de
Wed May 3 00:30:04 CEST 2006


hi iohannes,

Am Dienstag, 2. Mai 2006 12:47 schrieb IOhannes m zmoelnig:
> Christian Klippel wrote:
> > hi all,
> >
> > can anyone confirm that using outlet_anything() inside a thread is safe?
>
> i am pretty sure this assumption is illegal.
> the problem will arise as soon as a "normal" object will receive
> messages from both threads.
> if you "guarantee" (e.g. leave it at the users discretion :-)) that no
> unprepared object will be involved in several threads, the i guess you
> are on the safe side (but maybe you are not) (see tim's [detach]/[join]
> objects)
>

what do you mean by "unprepared objects" ? other objects that use threads too? 
as for the actual code in question, it creates only one single thread to read 
from the usb bus, and send data to the outlets if anything arrives. there are 
no other threads created.... an there are no variables/memory that the thread 
shares with the rest of the external's code, except for sending to usb, which 
is synchronized ....

what im wondering is, how can one stress-test such a situation to see if it  
works just by accident now, or if it is reliable ....

so far i am feeding the received data through a [select 0 1 2] and another one 
through [select 0 1 2 3] (two outlets that send data from within the thread).
the splitted streams (7) are then fed into [i] objects, faders and toggles. 
additionally i created some [metro 1] that bang the [i] and fader objects, to 
which normal numberboxes are connected ..... due to the many, fast running 
metro's i have a pretty high sysload, and surely there are messages sent 
almost always. but no crash, wrong data, or something.....

so im really wondering how that could work, if it isnt supposed to be safe to 
call outlet_anything from a (single) thread ....

and as tim said:

>solution 3: use flext, since it's taking care of that ...

tim, since i know nothing about flext (yet), just a few quick question (maybe 
i asked that loong ago alread....): does it work on linux/os-x/win? i need 
all three ....

but i will look into it a bit deeper anyway, thanks for the hints ..

chris

> generally however, i think you should do the synchronisation between
> several threads before using outlet_*()
>
> mfg.ad.r
> IOhannes
>
> _______________________________________________
> PD-dev mailing list
> PD-dev at iem.at
> http://lists.puredata.info/listinfo/pd-dev





More information about the Pd-dev mailing list