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

Thiago Macieira thiago at kde.org
Wed Dec 9 08:36:02 CET 2009


Em Quarta-feira 9. Dezembro 2009, às 03.30.59, Preet escreveu:
> I'm having a very strange problem with this methodology. I have readyRead()
> connected to a slot that simply prints out the number of bytesAvailable.
>  For some reason, after one round of I/O with my device, the bytesAvailable
>  is consistantly 0. Why would readyRead() even emit if this was the case?

It doesn't, not in Qt QIODevice classes.

Since this message thread is about multithreading (no pun intended), the 
problem is probably because you're using queued connections. When the 
readyRead() was emitted, bytesAvailable() was increasing. But due to a race 
condition, your slot read more than the first block read. That meant that the 
next readyRead() emissions that were queued were still delivered, but you had 
read everything already.

-- 
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
  Senior Product Manager - Nokia, Qt Development Frameworks
      PGP/GPG: 0x6EF45358; fingerprint:
      E067 918B B660 DBD1 105C  966C 33F5 F005 6EF4 5358
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 190 bytes
Desc: This is a digitally signed message part.
Url : http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20091209/a94f43b4/attachment.bin 


More information about the Qt-interest-old mailing list