Ian Main <imain / gtk.org> wrote:
> GTK has good facilities for this.. from looking through ruby source code
> again, it looks like ruby needs only:
> 
> * The ablity watch file descriptors for read/write readiness.
> * A timeout for sleep() and similar functions.

Yes, and select system call exactly provides these facilities.

And these facilities are also enough for GTK, aren't they?
So the simplest solution is the integration of select, IMHO.
Fortunately, GTK provides g_main_set_poll_func() for this purpose.

The advantage of this approach is the simplicity.  Both GTK and
Ruby can assume mainloop control.  GTK mainloop can be considered
as a Ruby thread.  Ruby thread scheduler yields the control to
GTK when GUI event occurs.

The problem with this approach:

 * Toolkit must provides select substitution API such as
   g_main_set_poll_func().  I don't know that other toolkits than
   GTK provide one.

 * rb_thread_select() needs improvement to avoid busy wait with
   more than one thread.  This involves eval.c hacking...

> Hopefully I am not missing any issues here.. if someone knows something I
> don't please let me know! :)

My approach lacks the point of embedding Ruby as your Entity.
Plese tell me if you find something wrong with this approach.


Masaki Fukushima