diff options
author | Marc Mutz <marc.mutz@kdab.com> | 2013-09-20 02:38:22 +0200 |
---|---|---|
committer | Marc Mutz <marc.mutz@kdab.com> | 2016-11-20 15:48:05 +0000 |
commit | 3691f7ca0c7117f18ea38ca3950ee9a8a91a53c8 (patch) | |
tree | c17a602be94f46bf51a51726bf0472aa51c1ecba /src/corelib/thread/qfutureinterface_p.h | |
parent | f1b4bd4790860e1ff5afcec111a359bc3a91cfda (diff) |
QFutureInterface: make accesses to 'state' thread-safe
Introduce helper functions switch_{on,off,from_to} to make
the code more readable, and prepare everything for later
optimizations reducing the sizes of critical sections (by
locking the mutex later, or even never).
This commit, however, is only concerned with shutting up
tsan.
In waitForResult(), simplified the code by removing an
unneeded if guard: the condition is checked in the while
loop immediately following in the then-block, and the
local variable declaration that precedes the loop is not
worth guarding.
Change-Id: I24bfd864ca96f862302536ad8662065e6f366fa8
Reviewed-by: David Faure <david.faure@kdab.com>
Diffstat (limited to 'src/corelib/thread/qfutureinterface_p.h')
-rw-r--r-- | src/corelib/thread/qfutureinterface_p.h | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/corelib/thread/qfutureinterface_p.h b/src/corelib/thread/qfutureinterface_p.h index e2d588cd07..eb0c38421b 100644 --- a/src/corelib/thread/qfutureinterface_p.h +++ b/src/corelib/thread/qfutureinterface_p.h @@ -155,7 +155,7 @@ public: int m_progressValue; // TQ int m_progressMinimum; // TQ int m_progressMaximum; // TQ - QFutureInterfaceBase::State state; + QAtomicInt state; // reads and writes can happen unprotected, both must be atomic QElapsedTimer progressTime; QWaitCondition pausedWaitCondition; QtPrivate::ResultStoreBase m_results; |