[Qt-interest] Temporarily 'ignoring' QIODevice::readyRead() in multithreaded app

Arnold Krille arnold at arnoldarts.de
Mon Dec 7 18:27:46 CET 2009


Hi,

On Monday 07 December 2009 16:33:12 Preet wrote:
> However the problem in this is that the device may generate a lot of data
>  at once, either repeatedly emitting readyRead() in my application, or
>  emitting readyRead() very sparsely. When a lot of data is generated
>  spontaneously, my signal handler (slot) is unable to finish execution
>  without being preempted by the readyRead() signal. I need a way to
>  'ignore' signals after receiving readyRead() initially, and then enable
>  signals once again when my signal handler function has completed
>  execution.

afaik, readyRead is emitted only when new data has arrived. But also every 
time when new data has arrived.
So when your slot isn't finished by the time the new signal arrives, that is 
not a problem per se as the next signal-slot will only execute afterwards.
The easiest solution is to read as long as data is in the iodevice. This will 
automatically join multiple readyRead signals when this fires while your slot 
is running. And the slot-calls after that will just do nothing because there 
is no more data in the devices buffer.

Is that explained understandable?

Have fun,

Arnold
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: This is a digitally signed message part.
Url : http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20091207/f809a4b4/attachment.bin 


More information about the Qt-interest-old mailing list