Re: [Fxruby-users] Connecting multiple listeners to an object
Status: Inactive
Brought to you by:
lyle
From: Lyle J. <ly...@kn...> - 2004-04-07 23:27:35
|
On Apr 4, 2004, at 8:49 PM, Daniel Sheppard wrote: > My original problem was with the SEL_UPDATE coming along too slowly and > having a very unresponsive gui unless I was explicitely forcing > updates. > > That was until I looked at the datatarget example and saw this: > > theApp.threadsEnabled = false > > Which I put into my code with much delight. What is the impact of this > flag? What threads are being disabled? Your GUI application usually runs under the main thread in the Ruby interpreter. If we didn't do anything to try to handle Ruby threads, all of the threads other than the main thread would be starved (i.e. they wouldn't get any time scheduled to them). The way that FOX's event loop interacts with Ruby's thread scheduler goes something like this: Whenever there is idle time in the GUI (i.e. all pending events have been processed), a special chore fires that yields a small amount of time to Ruby's thread scheduler. This allows other the other threads to run, but it obviously introduces some overhead into the FOX event loop. You have some control over how much overhead comes into play. One option is to modify the amount of time allocated to the thread scheduler during each idle period by setting the FXApp#sleepTime attribute (in milliseconds). The default "sleep" time (i.e. the amount of time the main loop sleeps while other threads are allowed to run) is 100ms. The other option, if you know that your application doesn't use any other threads, is to disable FXRuby's support for Ruby threads by setting FXApp#threadsEnabled to false. Hope this helps, Lyle |