qt-interest@trolltech.com
[Top] [All Lists]

Re: [Qt-interest] Proper way to terminate QThreads

Subject: Re: [Qt-interest] Proper way to terminate QThreads
From: Thiago Macieira
Date: Tue, 17 Nov 2009 20:27:04 +0100
Em Terça-feira 17 Novembro 2009, às 18:36:48, você escreveu:
> bool m_continue = true;
> 
> MyThread::run()
> {
>         while (m_continue)
>         {
>                 readFromSocket();
>                 processData();
>                 ...
>         }
> }
> 

Please remember to make that a volatile bool.

Otherwise the compiler can (correctly) assume that, if it enters the loop 
once, it doesn't ever have to exit that loop.

-- 
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
_______________________________________________
Qt-interest mailing list
Qt-interest@xxxxxxxxxxxxx
http://lists.trolltech.com/mailman/listinfo/qt-interest
<Prev in Thread] Current Thread [Next in Thread>