[fxruby-users] Performance of multithreaded FXRuby apps (was: FXColorDialog slow UI update)
lyle at lylejohnson.name
Thu Feb 28 08:56:35 EST 2008
On Feb 28, 2008, at 7:16 AM, Philippe Lang wrote:
> Thanks, it works just fine now. The problem disappeared. Is there a
> reason why multithreading slows down FXRuby so much?
It's related to the fact that Ruby doesn't use native threads, and
what I therefore have to do in FOX's event loop in order to ensure
that Ruby threads get scheduled.
FXRuby adds a chore that yields a little slice of time to Ruby's
thread scheduler whenever your application becomes idle. Even if you
don't *have* any other threads in your application, the FXRuby thread
will "sleep" for 100 milliseconds every time that chore runs. You can
adjust the amount of time that FXRuby yields to the thread scheduler
via the FXApp#sleepTime attribute, e.g.
app.sleepTime = 50 # only sleep for 50ms at a time
Or you can just disable it altogether (as Vlad pointed out) by calling
It's an ugly solution to a tricky problem, but it's all I could come
up with. I am willing to consider patches that implement alternative
solutions to the problem, however!
Hope this helps,
More information about the fxruby-users