[Interest] Terminating a QThread
Etienne Sandré-Chardonnal
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,
never read)
- 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.
Etienne
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
> http://lists.qt-project.org/mailman/listinfo/interest
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20130622/a7194c05/attachment.html>
More information about the Interest
mailing list