summaryrefslogtreecommitdiffstats
path: root/src/corelib/concurrent
diff options
context:
space:
mode:
authorMorten Sørvig <msorvig@trolltech.com>2009-06-26 08:56:41 (GMT)
committerMorten Sørvig <msorvig@trolltech.com>2009-06-26 13:15:14 (GMT)
commitb798c301d34f0f1ec69ca533bc91e575fac9843b (patch)
tree722a356e28a30e4466b19630e901c41aa7bf8ea1 /src/corelib/concurrent
parent8e9a6aca959336ef150021a858178fc3cd1ad426 (diff)
downloadQt-b798c301d34f0f1ec69ca533bc91e575fac9843b.zip
Qt-b798c301d34f0f1ec69ca533bc91e575fac9843b.tar.gz
Qt-b798c301d34f0f1ec69ca533bc91e575fac9843b.tar.bz2
De-export the ThreadEngineBarrier class and de-inline the call to acquire.
(ThreadEngineBarrier was implemented in the header as ThreadEngineSemaphore in Qt 4.4 and Qt 4.5, and exported for a brief time in the Qt master branch. ) Unfortunately the inline call to acquire means that applications compiled with Qt 4.4. and Qt 4.5 will contain a copy of the old implementation. This is BC as long as the memory layout of the ThreadEngineBarrier class stays the same, which means that we keep the QMutex member variable. The old version of acquire will no longer be thread-safe since the new version doesn't lock the mutex, but this is fortunately not a problem; the only place it's called is in startAsynchronously() before the worker threads are started.
Diffstat (limited to 'src/corelib/concurrent')
-rw-r--r--src/corelib/concurrent/qtconcurrentthreadengine.cpp5
-rw-r--r--src/corelib/concurrent/qtconcurrentthreadengine.h10
2 files changed, 13 insertions, 2 deletions
diff --git a/src/corelib/concurrent/qtconcurrentthreadengine.cpp b/src/corelib/concurrent/qtconcurrentthreadengine.cpp
index 150540a..c6bde85 100644
--- a/src/corelib/concurrent/qtconcurrentthreadengine.cpp
+++ b/src/corelib/concurrent/qtconcurrentthreadengine.cpp
@@ -176,6 +176,11 @@ void ThreadEngineBase::startThread()
startThreadInternal();
}
+void ThreadEngineBase::acquireBarrierSemaphore()
+{
+ barrier.acquire();
+}
+
bool ThreadEngineBase::isCanceled()
{
if (futureInterface)
diff --git a/src/corelib/concurrent/qtconcurrentthreadengine.h b/src/corelib/concurrent/qtconcurrentthreadengine.h
index 896b193..1f359fc 100644
--- a/src/corelib/concurrent/qtconcurrentthreadengine.h
+++ b/src/corelib/concurrent/qtconcurrentthreadengine.h
@@ -66,13 +66,18 @@ namespace QtConcurrent {
// The ThreadEngineBarrier counts worker threads, and allows one
// thread to wait for all others to finish. Tested for its use in
// QtConcurrent, requires more testing for use as a general class.
-class Q_CORE_EXPORT ThreadEngineBarrier
+class ThreadEngineBarrier
{
private:
// The thread count is maintained as an integer in the count atomic
// variable. The count can be either positive or negative - a negative
// count signals that a thread is waiting on the barrier.
+
+ // BC note: inlined code from Qt < 4.6 will expect to find the QMutex
+ // and QAtomicInt here. ### Qt 5: remove.
+ QMutex mutex;
QAtomicInt count;
+
QSemaphore semaphore;
public:
ThreadEngineBarrier();
@@ -103,6 +108,7 @@ public:
bool isProgressReportingEnabled();
void setProgressValue(int progress);
void setProgressRange(int minimum, int maximum);
+ void acquireBarrierSemaphore();
protected: // The user overrides these:
virtual void start() {}
@@ -170,7 +176,7 @@ public:
QFuture<T> future = QFuture<T>(futureInterfaceTyped());
start();
- barrier.acquire();
+ acquireBarrierSemaphore();
threadPool->start(this);
return future;
}