Bill Kelly wrote:
> From: "Joel VanderWerf" <vjoel / path.berkeley.edu>
>>
>> Can the ruby thread just Thread.sleep, and wait for the C++ code to call
>> rb_thread_wakeup() or whatever it is that implements Thread#wakeup ?
> 
> Hi - somehow i'd not seen your reply.  Thanks.
> 
> Hmm...
> 
> VALUE
> rb_thread_wakeup(thread)
>    VALUE thread;
> {
>    rb_thread_t th = rb_thread_check(thread);
> 
>    if (th->status == THREAD_KILLED)
>        rb_raise(rb_eThreadError, "killed thread");
>    rb_thread_ready(th);
> 
>    return thread;
> }
> 
> I don't suppose this could be called from a different OS thread
> than ruby's.

Not necessarily such a problem. rb_thread_wakeup() doesn't muck around
with any data structures that the thread scheduler uses. It just sets a
couple of fields in the thread object. So there's a race condition, and
a breaking of encapsulation, and a gnashing of teeth. But other than
that, possible.

> And the ruby interpreter may be waiting in a select() call when
> I need to wake up my ruby thread.

Oh. That's the real problem. You could keep one thread in a loop {sleep
epsilon}, but that's back to square one.

> Ah, well.. Maybe UDP is the way to go...   <smile>

Sounds like it is.

-- 
      vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407