[Qt-interest] Fwd: QAtomicInt and QThread

Mandeep Sandhu mandeepsandhu.chd at gmail.com
Fri Jun 24 15:12:26 CEST 2011


>> What you need for protecting the atomicity of read/write ops between
>> threads is mutex. eg: you use QMutex from serializing access to the
>> shared data.
> Is it not enough to use a QAtomicInt? From the docs the "=" and "=="
> operators seems to be atomic on QAtomicInt. So that way at least the
> last example should work.

For your specific case of reading/writing integer values, it might
suffice. Though I've never used it myself so maybe someone else on the
list can confirm?

Mutex's are used for more 'general' purpose access serialization,
like reading/writing multiple bytes of data.

HTH,
-mandeep

>>
>> HTH,
>> -mandeep
>>
>>> _______________________________________________
>>> Qt-interest mailing list
>>> Qt-interest at qt.nokia.com
>>> http://lists.qt.nokia.com/mailman/listinfo/qt-interest
>>>
>>
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at qt.nokia.com
> http://lists.qt.nokia.com/mailman/listinfo/qt-interest
>



More information about the Qt-interest-old mailing list