[Kde-bindings] Using threads with QtRuby

Richard Dale rdale at foton.es
Mon Feb 8 20:14:05 UTC 2010


On Saturday 06 February 2010 12:53:11 pm Robert Riemann wrote:
> Maybe we should concentrate on why it is working with gtk instead of
> integrating the workaround
> to the bindings. After all, exec_with_threads would be a method that
> doesn't exist in c++ Qt.
Well I think Uriel's idea of calling the threads Qt::Thread and starting a 
Qt::Timer in the thread itself would mean we don't have to have a special 
exec() anymore. I'm not too bothered about how GTK ruby works, but it would be 
interesting if someone could find out.

> 
> 2010/2/5 Richard Dale <rdale at foton.es>:
> > On Friday 05 February 2010 04:55:28 pm Uriel wrote:
> >> Thanks for your answers.
> >>
> >> > Thats strange because Qt on my system uses to same glib event loop as
> >> > GTK uses
> >> > and QtRuby still doesn't work well with Ruby threads as you say. Maybe
> >> > GTK
> >> > ruby is using some hook to periodically run code in threads I don't
> >> > know.
> >> >
> >> > Threads in Ruby 1.8.x are really just broken, but it might be possible
> >> > to get
> >> > QtRuby and Ruby threads working with Ruby 1.9.x.
> >>
> >> Sorry for not telling you about versions of packages I'm using.
> >> I'm on ArchLinux and have latest build of all packages. So Ruby is
> >> 1.9.1, QtRuby is in package kdebindings-ruby 4.3.4, Qt is 4.5.3, glib is
> >> 2.22.4 and GTK is 2.18.6 if it's important. :)
> >> So then I'll try to find out how GtkRuby works with threads.
> >>
> >> > This is basically what I do to make threads work which seems to work
> >> > great.  By calling Ruby's sleep method in a Timer, you allow the Ruby
> >> > thread scheduler to run:
> >>
> >> This is really works great for me, thank you very much.
> >> But would it be wrong to go a bit more further and add some extra code
> >> to Qt::Application?
> >> Something like that:
> >>
> >> class Qt::Application
> >> protected
> >>    def timerEvent(ev)
> >>      sleep 0.001
> >>    end
> >> public
> >>    alias :__oldExec :exec
> >>    def exec
> >>      startTimer 0
> >>      __oldExec
> >>    end
> >> end
> >>
> >> It can be more 'advanced': start timer only when new instance of the
> >> Thread class is created and stop when there is no more threads left.
> >
> > Looks a good idea. Maybe rather than alias the standard exec() we could
> > add an exec_with_threads() method?
> >
> > -- Richard
> > _______________________________________________
> > Kde-bindings mailing list
> > Kde-bindings at kde.org
> > https://mail.kde.org/mailman/listinfo/kde-bindings
> 
> _______________________________________________
> Kde-bindings mailing list
> Kde-bindings at kde.org
> https://mail.kde.org/mailman/listinfo/kde-bindings
> 



More information about the Kde-bindings mailing list