From ruby-talk Wed Dec 26 18:22:01 2007 From: "=?ISO-8859-1?Q?daniel_=E5kerud?=" Date: Wed, 26 Dec 2007 18:22:01 +0000 To: ruby-talk Subject: Re: qt4 bindings, threads Message-Id: X-MARC-Message: https://marc.info/?l=ruby-talk&m=119869338404889 MIME-Version: 1 Content-Type: multipart/mixed; boundary="------=_Part_18809_15011674.1198693325514" ------=_Part_18809_15011674.1198693325514 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline If anyone has the same problem in the future: I solved this problem by usin= g a Qt::Timer, that polls the UNIX domain socket every 100ms. At every poll i= t 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 =3D @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 =E5kerud wrote: > On Dec 26, 2007 10:35 AM, Stefano Crocco wrote: > > > Alle mercoled=EC 26 dicembre 2007, daniel =E5kerud 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=3D723 > > > > As for your question about threads, they're discussed in these two > > threads in > > the forum: > > http://rubyforge.org/forum/message.php?msg_id=3D3319 > > http://rubyforge.org/forum/forum.php?thread_id=3D14559&forum_id=3D723 > > > > I hope this helps > > > > Stefano > > > > > > Thank you very much!! > > /D > > > ------=_Part_18809_15011674.1198693325514--