From: Francis C. [mailto:[email protected]]
Sent: Friday, June 30, 2006 6:29 AM
sleep(10000) is a Ruby call, not a native one. It’s aware that other Ruby
threads are running. Try doing the same thing on your native thread with a
native API (I forget what that millisecond-sleep API is on Windows)-
find that it blocks your program just as the event loop did.
OK, I’ve got it.
Hmmm… Ok, I’ll try. But I think there must be more general solution
threading C extension. No?<<<<<<<<<<<<<<<<<
You’re wandering into the strange land of native/green thread interaction.
won’t be the one to start yet another rehash of this subject ;-). If
trying to run the Windows GUI event loop, why not just use Ruby tk?
Because I’m doing my own GUI library :)))
BTW, here is the solution of my problem (and thank you, the solution was
very close to your advice!):
static VALUE run(VALUE _self)
::PeekMessage(&msg, NULL, 0, 0, PM_REMOVE); //the 1st
gotcha! We need Peek, not Get message
if(msg.message == WM_QUIT) break;
rb_thread_schedule(); //second gotcha! Give ruby’s scheduler
the possibility to switch