From: Patrick Hurley Date: 2006-06-21T05:17:15+09:00 Subject: Re: C Threads and Ruby On 6/20/06, Paul Brannan wrote: > On Wed, Jun 21, 2006 at 01:39:53AM +0900, Patrick Hurley wrote: > > That is not true, it is completely possible to use an OS level > > mutex/critical section etc, from inside a "green" Ruby thread. It will > > block all Ruby threads which is not very nice, but I do not know of a > > better solution. > > TRAP_BEG and TRAP_END work well for allowing Ruby to switch threads, > though the call between them must be interruptible. I believe this > should be true of sem_wait(), though I've been unsuccessful interrupting > it on linux. > > I typically use a pipe for this kind of synchronization. > > Paul > > > > I would agree a pipe is generally better; however, in my case it was against a Win32 API that required the use of threads. Now I am curious about TRAP_BEG/TRAP_END. Is it safe to access rb_XXX methods from inside a TRAP_BEG/TRAP_END block not in the ruby interpreter thread? If so that would make some things much easier. Thanks pth