[Qt-interest] QAtomicInt and QThread

Thiago Macieira thiago at kde.org
Fri Jun 24 11:38:31 CEST 2011


On Friday, 24 de June de 2011 10:46:44 Francisco Gonzalez wrote:
> this example compiles and run ok, but is it correct?

Maybe it is. We don't know what you're trying to do.

We can't tell if it is correct or not if we don't know what it's supposed to 
do and what the conditions are. Please explain them too.

I see some manipulation of a non-atomic 64-bit int inside a loop and reading 
of the same 64-bit integer from another function. Since you didn't try to use 
the atomic there, I don't suppose you care that this is non-atomic and can 
produce weird results.

I see also the use of QAtomicInt for something a volatile bool would be 
enough. If this was meant as the control mechanism for the thread, the most 
correct operations are loadAcquire and storeRelease, which we haven't 
unfortunately added to Qt.

-- 
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
      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/20110624/46fb9267/attachment.bin 


More information about the Qt-interest-old mailing list