diff options
author | Thiago Macieira <thiago.macieira@nokia.com> | 2011-02-16 10:06:08 (GMT) |
---|---|---|
committer | Thiago Macieira <thiago.macieira@nokia.com> | 2011-02-16 10:32:06 (GMT) |
commit | df129c2449181869f0b95ae92d174b9eca52b2f7 (patch) | |
tree | f8546da86329e16619d6da735cf8fcb2cc47d388 /tests/auto | |
parent | 89b754d30eaa5c9c57fb50bc563a3c60cc314c4e (diff) | |
download | Qt-df129c2449181869f0b95ae92d174b9eca52b2f7.zip Qt-df129c2449181869f0b95ae92d174b9eca52b2f7.tar.gz Qt-df129c2449181869f0b95ae92d174b9eca52b2f7.tar.bz2 |
Add a mutex to protect the access to the QSet.
In theory, there should be no problems with doing this unlocked,
as the test should only run one thread at a time in this particular
code section.
In practice, if the test is failing, multiple threads would be
modifying the QSet. So the mutex is necessary to detect the
test failing.
Reviewed-By: Morten Sørvig
Diffstat (limited to 'tests/auto')
-rw-r--r-- | tests/auto/qtconcurrentiteratekernel/tst_qtconcurrentiteratekernel.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/tests/auto/qtconcurrentiteratekernel/tst_qtconcurrentiteratekernel.cpp b/tests/auto/qtconcurrentiteratekernel/tst_qtconcurrentiteratekernel.cpp index a6499ff..92e8608 100644 --- a/tests/auto/qtconcurrentiteratekernel/tst_qtconcurrentiteratekernel.cpp +++ b/tests/auto/qtconcurrentiteratekernel/tst_qtconcurrentiteratekernel.cpp @@ -201,6 +201,7 @@ void tst_QtConcurrentIterateKernel::noIterations() startThreadEngine(new IterateKernel<TestIterator, void>(0, 0)).startBlocking(); } +QMutex threadsMutex; QSet<QThread *> threads; class ThrottleFor : public IterateKernel<TestIterator, void> { @@ -219,8 +220,10 @@ public: QThread *thread = QThread::currentThread(); - if (begin > 140 && end < 160) + if (begin > 140 && end < 160) { + QMutexLocker locker(&threadsMutex); threads.insert(thread); + } if (100 >= begin && 100 < end) { throttling = true; |