Threading in Plasma applets

Richard Dale richard.j.dale at gmail.com
Tue Feb 19 22:54:34 CET 2008


On 2/19/08, Sebastian Sauer <mail at dipe.org> wrote:
> On Tuesday 19 February 2008, Aaron J. Seigo wrote:
> > On Tuesday 19 February 2008, Richard Dale wrote:
> > > were having problems too, which makes me think it might be some sort
> > > of Ruby problem, rather than a QtRuby specific problem. Is that
> > > possible?
> >
> > could be.. and yes, the kross based ScripEngines were dieing badly in
> > threading related deaths while the same engines when running python scripts
> > work fine.
>
> well, threading should work. The reason why it was failing, is that there is
> still a bit of testingcode within krossruby that doesn't seem to be
> thread-safe (yet). Someone is able to work around this by removing the
> #define KROSS_RUBY_EXPLICIT_GC
> in kdebindings/ruby/krossruby/rubyconfig.h (should also increase the speed a
> lot, that code does run the garbage collector at each possible step to
> discover problems faster, but seems the gc is not very thread-friendly ;)
>
> @richard; normaly it should be enough to;
> const int critical = rb_thread_critical;
> rb_thread_critical = Qtrue;
> e.g. rb_funcall() ... (and while on that code, it may also an idea to wrap
> rb_funcall's into rb_rescue2's to catch exceptions and prevent
> rb_bug's/crashes and, not sure if that's really needed, to ruby_in_eval++ and
> ruby_in_eval-- to prevent infinite loop's)
> rb_thread_critical = critical;
>
> Anyway. I still try to get the
> playground/base/plasma/scriptengines/kross/examples/example_ruby_runner
> working, but seems it still fails somehow. So, I am not able to test it aka
> look if there are probably more bugs related to threading :-/
>
> Attached is the patch I applied. I guess atm the problem is, that the
> match+exec methods in kdebase/libs/plasma/scripting/runnerscript.h arn't
> virtual any longer. So, somehow I miss how it needs to be changed to work
> again :-/
That's very interesting - I'd never heard of rb_thread_critical. It
does sound like that might do it for qtruby as well as kross. I was
under the impression that ruby has its own heap, and as long as ruby
code only executed in one thread it would work fine. From what you say
that isn't true. I also need to add the exception handling so that
plasma doesn't crash when there is a ruby exception.

-- Richard


More information about the Panel-devel mailing list