[Kde-bindings] Using threads with QtRuby

Robert Riemann robert.riemann at physik.hu-berlin.de
Sat Feb 6 12:53:11 UTC 2010


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.

Robert

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
>
>



More information about the Kde-bindings mailing list