[prev in list] [next in list] [prev in thread] [next in thread]
List: ruby-talk
Subject: Re: qt4 bindings, threads
From: "=?ISO-8859-1?Q?daniel_=E5kerud?=" <daniel.akerud () gmail ! com>
Date: 2007-12-26 18:22:01
Message-ID: b000da060712261022x6549614ai33444cc44e7137c () mail ! gmail ! com
[Download RAW message or body]
If anyone has the same problem in the future: I solved this problem by using
a Qt::Timer, that polls the UNIX domain socket every 100ms. At every poll it
reads data with socket.read_nonblock until it throws a Errno::EAGAIN, like
this:
40 # poll data from socket, until there is no more
41 begin
42 begin # loop while read_nonblock returns data
43 new_data, addr_arr = @socket.read_nonblock(128)
44 data << new_data
45 end while true
46 rescue Errno::EAGAIN
47 # no more data
48 end
Much cleaner than using a thread, IMO.
/D
On Dec 26, 2007 11:18 AM, daniel åkerud <daniel.akerud@gmail.com> wrote:
> On Dec 26, 2007 10:35 AM, Stefano Crocco <stefano.crocco@alice.it> wrote:
>
> > Alle mercoledì 26 dicembre 2007, daniel åkerud ha scritto:
> > > I couldn't find a mailinglist for the Qt4 Ruby bindings, so I try
> > here. It
> > > seems the Qt4 Ruby bindings lack Qt::Thread. So how do I create a
> > Thread?
> > > Do I use Ruby's build-in? I need a thread because I need to read from
> > a
> > > UNIX domain socket (blocking), and pass the data to the GUI. Thanks
> > for any
> > > help!
> > >
> > > /D
> >
> > There's a forum for qtruby. It's at rubyforge, and the name of the
> > project is
> > korundum. The address of the forum is:
> > http://rubyforge.org/forum/forum.php?forum_id=723
> >
> > As for your question about threads, they're discussed in these two
> > threads in
> > the forum:
> > http://rubyforge.org/forum/message.php?msg_id=3319
> > http://rubyforge.org/forum/forum.php?thread_id=14559&forum_id=723
> >
> > I hope this helps
> >
> > Stefano
> >
> >
>
> Thank you very much!!
>
> /D
>
>
>
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic