[Interest] Terminating a QThread
etienne.sandre at m4x.org
Sat Jun 22 08:45:00 CEST 2013
Except in this particular case where:
- The flag is set to false at the start of the thread
- Set to true for stopping by the controlling(parent) thread (writen,
- Checked by the thread as a quit condition (read, never written)
In that case, there is absolutely no possible race condition & undefined
state. No thread makes composite access (fetch and set, fetch & add, etc...)
OK, that's not worth the discussion since the cost of atomic is negligible
and it's definitely a better habit to use atomics everywhere for values
accessed between threads.
2013/6/22 Thiago Macieira <thiago.macieira at intel.com>
> On sábado, 22 de junho de 2013 12.41.10, Tony Rietwyk wrote:
> > But a bool value can be cached indefinitely, so make sure you declare the
> > flag as volatile!
> That's wrong and has been explained away several times. You need to
> declare it
> as atomic, not as volatile.
> Thiago Macieira - thiago.macieira (AT) intel.com
> Software Architect - Intel Open Source Technology Center
> Interest mailing list
> Interest at qt-project.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Interest