[PD-dev] Is gensym() threadsafe?

Kjetil S. Matheussen kjetil at ccrma.stanford.edu
Tue Dec 13 22:14:39 CET 2005


On Tue, 13 Dec 2005, Tim Blechmann wrote:

> hi kjetil,
>
>> I'm working on the snd external, and wonder about gensyms thread
>> safety. It looks to be, but I'm not quite sure. In case it isn't
>> is there a locking-mechanism or something I can use?
>>
>> I also see that there are some functions called sys_lock or
>> something, how does they work?
>
> gensym is basically not thread safe ... for the devel branch i made
> gensym threadsafe, but if you want to write code for miller's pd, you
> need to use the syslock ...
>

Thanks! So how do I use syslock from another thread?

Does this make sence:?

t_symbol *thread_safe_gensym(char *symbol){
  t_symbol *ret;
  sys_lock();
  ret=gensym(symbol);
  sys_unlock();
  return ret;
}


-- 




More information about the Pd-dev mailing list