[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-29 19:02:42
Message-ID: b000da060712291102y3008407am870bdd6e6c56e072 () mail ! gmail ! com
[Download RAW message or body]


On Dec 26, 2007 7:22 PM, daniel åkerud <daniel.akerud@gmail.com> wrote:

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

Update to this: QSocketNotifier is indeed they way to go. I think I tried
Qt::QSocketNotifier instead of Qt::SocketNotifier by mistake earlier.

/D


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic