From: Ian Main Date: 2000-02-27T11:34:56-08:00 Subject: [ruby-talk:01600] Re: Ruby/GTK and the mainloop On Sat, Feb 26, 2000 at 03:51:32PM +0900, Masaki Fukushima wrote: > Ian Main 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. Yes, select() more less == mainloop in terminology. > 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. and g_timeout_add for sleep () etc. right ? This is what I was thinking. > * 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. I think we are both thinking the same thing, so it should be fine. I beleive most other toolkits provide similar functions. Entity uses GTK, so really, if you can get gtk and ruby working nicely, it should embed nicely in Entity too. Ian