From: Patrick Hurley [mailto:phur...@gmail.com]
Sent: Tuesday, June 20, 2006 1:29 PM
It depends what you are trying to do. I just worked up a patch to
win32-service, that does this by creating a ruby thread in the C
extension that polls against a simple integer guarded by a mutex --
when an event occurs it is signaled there and the correct call back is
spun off in yet another ruby thread. I was worried this would be
"expensive", but the rb_thread_polling method, worked like a charm.
Yeah, I'm doing something simmilar with rb_thread_wait_for instead of
rb_thread_polling. rb_thread_polling does sleep for 6ms. While this may
be acceptable it is not exactly what I was looking for. (I'm sleeping
for
only 1ms and there is no noticeable cpu requirement)
Perhaps my problem is: I just hate polling.
This idea could be easily extended to allow for an event queue that
was filled by a native C thread and processed by a ruby thread. Note
that calling any rb_XXXX from anything other than the "ruby thread" is
a really bad idea.
pth
thanks anyway,
Simon