From: Alex <x37...@gm...> - 2007-11-16 20:20:47
|
so this approach [the ruby only method] still uses up a lot of cpu as it has that timeout that keeps being called.. I added a 'sleep 0.001' to simulate something happening more async like... I have created my own, much simpler approach, it spawns a lot of timeout events but it doesn't peg the cpu. Comments? -Alex On Nov 16, 2007 11:45 AM, Mathieu Blondel <mbl...@ru...> wrote: > Drake Wilson wrote: > > An obvious interface to have would be a way of pushing blocks to the > > main loop; I see people in the mailing list archives doing this, but > > either they do it with timeouts (which results in continual polling, > > which is poor design) or... what? I don't see people obviously doing > > it any other way. > I have to agree that having a timeout running all the time in the > background is really not ideal... > > I came up with the attached solution. It starts the timeout when > necessary and stops it when it is no longer necessary, automatically. > I've quickly tested this solution in my app and it seems to work. > > Some remarks and questions: > > - It may be best to use module GLib instead of module Gtk > - Since I'm checking the number of running threads in the timeout, is it > subject to race conditions? > - I'm protecting Gtk::Thread.number with a mutex but I'm not sure > whether it's necessary or not > > What do you think Drake? And you Guillaume? Anyone? > > Thanks, > Mathieu > > ------------------------------------------------------------------------- > This SF.net email is sponsored by: Microsoft > Defy all challenges. Microsoft(R) Visual Studio 2005. > http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ > _______________________________________________ > ruby-gnome2-devel-en mailing list > rub...@li... > https://lists.sourceforge.net/lists/listinfo/ruby-gnome2-devel-en > > |