Hi,

At Fri, 7 May 2004 03:55:54 +0900,
Vincenzo Piombo wrote in [ruby-talk:99416]:
> I am working at a ruby application that needs to be notified of some hw 
> event provided by third party driver/DLL. It should run on Win32.
> The hardware events are generated in the context of a native win32 thread, 
> and I need to handle them in some ruby code. The main ruby process is 
> meanwhile used to handle a TCP/IP dialog with a GUI.
> 
> So basically I need an event queue which a ruby thread can suspend on, 
> waiting for events pushed in the queue by a win32 native thread.
> 
> I did some experiment with ruby API in a ruby extension but didn't succeed 
> to make it work.
> Can you guys tell me whether I'm trying something plainly impossible (in 
> that case are there alternatives ?) or am I just making some implementation 
> error ?

Current ruby interpreter implementation doesn't allow to be
called from other native threads.

A) You may be possible to use rb_w32_main_context(), which
   signals the main thread (native thread on which ruby runs),
   handshakes with it and invokes the given function in it.

B) Once I wrote a patch to improve IO.select issue, which it
   also provides rb_w32_wait_for_handle() function.
     http://nokada.jin.gr.jp/ruby/win32/wait_events.diff
   Note that it absolutely is untested.

-- 
Nobu Nakada