summaryrefslogtreecommitdiffstats
path: root/src/corelib/thread
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib/thread')
-rw-r--r--src/corelib/thread/qatomic.cpp72
-rw-r--r--src/corelib/thread/qbasicatomic.h4
-rw-r--r--src/corelib/thread/qgenericatomic.h6
-rw-r--r--src/corelib/thread/qmutexpool.cpp3
-rw-r--r--src/corelib/thread/qmutexpool_p.h2
-rw-r--r--src/corelib/thread/qsemaphore.cpp4
-rw-r--r--src/corelib/thread/qthread.cpp32
-rw-r--r--src/corelib/thread/qthread.h3
-rw-r--r--src/corelib/thread/qthread_unix.cpp2
-rw-r--r--src/corelib/thread/qthreadpool.cpp25
-rw-r--r--src/corelib/thread/qthreadpool_p.h1
-rw-r--r--src/corelib/thread/qthreadstorage.cpp4
-rw-r--r--src/corelib/thread/qwaitcondition.qdoc8
13 files changed, 52 insertions, 114 deletions
diff --git a/src/corelib/thread/qatomic.cpp b/src/corelib/thread/qatomic.cpp
index 5443d6e1b6..2e3029f3fa 100644
--- a/src/corelib/thread/qatomic.cpp
+++ b/src/corelib/thread/qatomic.cpp
@@ -83,16 +83,16 @@
\list
- \o Relaxed - memory ordering is unspecified, leaving the compiler
+ \li Relaxed - memory ordering is unspecified, leaving the compiler
and processor to freely reorder memory accesses.
- \o Acquire - memory access following the atomic operation (in
+ \li Acquire - memory access following the atomic operation (in
program order) may not be re-ordered before the atomic operation.
- \o Release - memory access before the atomic operation (in program
+ \li Release - memory access before the atomic operation (in program
order) may not be re-ordered after the atomic operation.
- \o Ordered - the same Acquire and Release semantics combined.
+ \li Ordered - the same Acquire and Release semantics combined.
\endlist
@@ -180,25 +180,25 @@
\list
- \o Q_ATOMIC_INT_REFERENCE_COUNTING_IS_ALWAYS_NATIVE
- \o Q_ATOMIC_INT_REFERENCE_COUNTING_IS_SOMETIMES_NATIVE
- \o Q_ATOMIC_INT_REFERENCE_COUNTING_IS_NOT_NATIVE
- \o Q_ATOMIC_INT_REFERENCE_COUNTING_IS_WAIT_FREE
+ \li Q_ATOMIC_INT_REFERENCE_COUNTING_IS_ALWAYS_NATIVE
+ \li Q_ATOMIC_INT_REFERENCE_COUNTING_IS_SOMETIMES_NATIVE
+ \li Q_ATOMIC_INT_REFERENCE_COUNTING_IS_NOT_NATIVE
+ \li Q_ATOMIC_INT_REFERENCE_COUNTING_IS_WAIT_FREE
- \o Q_ATOMIC_INT_TEST_AND_SET_IS_ALWAYS_NATIVE
- \o Q_ATOMIC_INT_TEST_AND_SET_IS_SOMETIMES_NATIVE
- \o Q_ATOMIC_INT_TEST_AND_SET_IS_NOT_NATIVE
- \o Q_ATOMIC_INT_TEST_AND_SET_IS_WAIT_FREE
+ \li Q_ATOMIC_INT_TEST_AND_SET_IS_ALWAYS_NATIVE
+ \li Q_ATOMIC_INT_TEST_AND_SET_IS_SOMETIMES_NATIVE
+ \li Q_ATOMIC_INT_TEST_AND_SET_IS_NOT_NATIVE
+ \li Q_ATOMIC_INT_TEST_AND_SET_IS_WAIT_FREE
- \o Q_ATOMIC_INT_FETCH_AND_STORE_IS_ALWAYS_NATIVE
- \o Q_ATOMIC_INT_FETCH_AND_STORE_IS_SOMETIMES_NATIVE
- \o Q_ATOMIC_INT_FETCH_AND_STORE_IS_NOT_NATIVE
- \o Q_ATOMIC_INT_FETCH_AND_STORE_IS_WAIT_FREE
+ \li Q_ATOMIC_INT_FETCH_AND_STORE_IS_ALWAYS_NATIVE
+ \li Q_ATOMIC_INT_FETCH_AND_STORE_IS_SOMETIMES_NATIVE
+ \li Q_ATOMIC_INT_FETCH_AND_STORE_IS_NOT_NATIVE
+ \li Q_ATOMIC_INT_FETCH_AND_STORE_IS_WAIT_FREE
- \o Q_ATOMIC_INT_FETCH_AND_ADD_IS_ALWAYS_NATIVE
- \o Q_ATOMIC_INT_FETCH_AND_ADD_IS_SOMETIMES_NATIVE
- \o Q_ATOMIC_INT_FETCH_AND_ADD_IS_NOT_NATIVE
- \o Q_ATOMIC_INT_FETCH_AND_ADD_IS_WAIT_FREE
+ \li Q_ATOMIC_INT_FETCH_AND_ADD_IS_ALWAYS_NATIVE
+ \li Q_ATOMIC_INT_FETCH_AND_ADD_IS_SOMETIMES_NATIVE
+ \li Q_ATOMIC_INT_FETCH_AND_ADD_IS_NOT_NATIVE
+ \li Q_ATOMIC_INT_FETCH_AND_ADD_IS_WAIT_FREE
\endlist
@@ -658,16 +658,16 @@
\list
- \o Relaxed - memory ordering is unspecified, leaving the compiler
+ \li Relaxed - memory ordering is unspecified, leaving the compiler
and processor to freely reorder memory accesses.
- \o Acquire - memory access following the atomic operation (in
+ \li Acquire - memory access following the atomic operation (in
program order) may not be re-ordered before the atomic operation.
- \o Release - memory access before the atomic operation (in program
+ \li Release - memory access before the atomic operation (in program
order) may not be re-ordered after the atomic operation.
- \o Ordered - the same Acquire and Release semantics combined.
+ \li Ordered - the same Acquire and Release semantics combined.
\endlist
@@ -753,20 +753,20 @@
\list
- \o Q_ATOMIC_POINTER_TEST_AND_SET_IS_ALWAYS_NATIVE
- \o Q_ATOMIC_POINTER_TEST_AND_SET_IS_SOMETIMES_NATIVE
- \o Q_ATOMIC_POINTER_TEST_AND_SET_IS_NOT_NATIVE
- \o Q_ATOMIC_POINTER_TEST_AND_SET_IS_WAIT_FREE
+ \li Q_ATOMIC_POINTER_TEST_AND_SET_IS_ALWAYS_NATIVE
+ \li Q_ATOMIC_POINTER_TEST_AND_SET_IS_SOMETIMES_NATIVE
+ \li Q_ATOMIC_POINTER_TEST_AND_SET_IS_NOT_NATIVE
+ \li Q_ATOMIC_POINTER_TEST_AND_SET_IS_WAIT_FREE
- \o Q_ATOMIC_POINTER_FETCH_AND_STORE_IS_ALWAYS_NATIVE
- \o Q_ATOMIC_POINTER_FETCH_AND_STORE_IS_SOMETIMES_NATIVE
- \o Q_ATOMIC_POINTER_FETCH_AND_STORE_IS_NOT_NATIVE
- \o Q_ATOMIC_POINTER_FETCH_AND_STORE_IS_WAIT_FREE
+ \li Q_ATOMIC_POINTER_FETCH_AND_STORE_IS_ALWAYS_NATIVE
+ \li Q_ATOMIC_POINTER_FETCH_AND_STORE_IS_SOMETIMES_NATIVE
+ \li Q_ATOMIC_POINTER_FETCH_AND_STORE_IS_NOT_NATIVE
+ \li Q_ATOMIC_POINTER_FETCH_AND_STORE_IS_WAIT_FREE
- \o Q_ATOMIC_POINTER_FETCH_AND_ADD_IS_ALWAYS_NATIVE
- \o Q_ATOMIC_POINTER_FETCH_AND_ADD_IS_SOMETIMES_NATIVE
- \o Q_ATOMIC_POINTER_FETCH_AND_ADD_IS_NOT_NATIVE
- \o Q_ATOMIC_POINTER_FETCH_AND_ADD_IS_WAIT_FREE
+ \li Q_ATOMIC_POINTER_FETCH_AND_ADD_IS_ALWAYS_NATIVE
+ \li Q_ATOMIC_POINTER_FETCH_AND_ADD_IS_SOMETIMES_NATIVE
+ \li Q_ATOMIC_POINTER_FETCH_AND_ADD_IS_NOT_NATIVE
+ \li Q_ATOMIC_POINTER_FETCH_AND_ADD_IS_WAIT_FREE
\endlist
diff --git a/src/corelib/thread/qbasicatomic.h b/src/corelib/thread/qbasicatomic.h
index 96338c62dc..01a69dbd8b 100644
--- a/src/corelib/thread/qbasicatomic.h
+++ b/src/corelib/thread/qbasicatomic.h
@@ -136,7 +136,7 @@ public:
// Atomic API, implemented in qatomic_XXX.h
- T loadAcquire() { return Ops::loadAcquire(_q_value); }
+ T loadAcquire() const { return Ops::loadAcquire(_q_value); }
void storeRelease(T newValue) { Ops::storeRelease(_q_value, newValue); }
static bool isReferenceCountingNative() { return Ops::isReferenceCountingNative(); }
@@ -206,7 +206,7 @@ public:
void store(Type newValue) { _q_value = newValue; }
// Atomic API, implemented in qatomic_XXX.h
- Type loadAcquire() { return Ops::loadAcquire(_q_value); }
+ Type loadAcquire() const { return Ops::loadAcquire(_q_value); }
void storeRelease(Type newValue) { Ops::storeRelease(_q_value, newValue); }
static bool isTestAndSetNative() { return Ops::isTestAndSetNative(); }
diff --git a/src/corelib/thread/qgenericatomic.h b/src/corelib/thread/qgenericatomic.h
index f4d5e2f8d9..34c040c39b 100644
--- a/src/corelib/thread/qgenericatomic.h
+++ b/src/corelib/thread/qgenericatomic.h
@@ -85,7 +85,7 @@ template <typename BaseClass> struct QGenericAtomicOps
static void orderedMemoryFence() { }
template <typename T> static inline always_inline
- T load(T &_q_value)
+ T load(const T &_q_value)
{
return _q_value;
}
@@ -97,9 +97,9 @@ template <typename BaseClass> struct QGenericAtomicOps
}
template <typename T> static inline always_inline
- T loadAcquire(T &_q_value)
+ T loadAcquire(const T &_q_value)
{
- T tmp = *static_cast<volatile T *>(&_q_value);
+ T tmp = *static_cast<const volatile T *>(&_q_value);
BaseClass::acquireMemoryFence();
return tmp;
}
diff --git a/src/corelib/thread/qmutexpool.cpp b/src/corelib/thread/qmutexpool.cpp
index b102770d23..6b6674ccdf 100644
--- a/src/corelib/thread/qmutexpool.cpp
+++ b/src/corelib/thread/qmutexpool.cpp
@@ -46,9 +46,6 @@
QT_BEGIN_NAMESPACE
-// qt_global_mutexpool is here for backwards compatibility only,
-// use QMutexpool::instance() in new clode.
-Q_CORE_EXPORT QMutexPool *qt_global_mutexpool = 0;
Q_GLOBAL_STATIC_WITH_ARGS(QMutexPool, globalMutexPool, (QMutex::Recursive))
/*!
diff --git a/src/corelib/thread/qmutexpool_p.h b/src/corelib/thread/qmutexpool_p.h
index ce55a40bb8..f5428bed52 100644
--- a/src/corelib/thread/qmutexpool_p.h
+++ b/src/corelib/thread/qmutexpool_p.h
@@ -84,8 +84,6 @@ private:
QMutex::RecursionMode recursionMode;
};
-extern Q_CORE_EXPORT QMutexPool *qt_global_mutexpool;
-
QT_END_NAMESPACE
#endif // QT_NO_THREAD
diff --git a/src/corelib/thread/qsemaphore.cpp b/src/corelib/thread/qsemaphore.cpp
index 52f5a1d699..08952eeaa3 100644
--- a/src/corelib/thread/qsemaphore.cpp
+++ b/src/corelib/thread/qsemaphore.cpp
@@ -66,10 +66,10 @@ QT_BEGIN_NAMESPACE
release():
\list
- \o acquire(\e{n}) tries to acquire \e n resources. If there aren't
+ \li acquire(\e{n}) tries to acquire \e n resources. If there aren't
that many resources available, the call will block until this
is the case.
- \o release(\e{n}) releases \e n resources.
+ \li release(\e{n}) releases \e n resources.
\endlist
There's also a tryAcquire() function that returns immediately if
diff --git a/src/corelib/thread/qthread.cpp b/src/corelib/thread/qthread.cpp
index a071463178..ea6760a1b9 100644
--- a/src/corelib/thread/qthread.cpp
+++ b/src/corelib/thread/qthread.cpp
@@ -42,7 +42,6 @@
#include "qthread.h"
#include "qthreadstorage.h"
#include "qmutex.h"
-#include "qmutexpool_p.h"
#include "qreadwritelock.h"
#include "qabstracteventdispatcher.h"
@@ -537,33 +536,6 @@ void QThread::run()
(void) exec();
}
-/*! \internal
- Initializes the QThread system.
-*/
-#if defined (Q_OS_WIN)
-void qt_create_tls();
-#endif
-
-void QThread::initialize()
-{
- if (qt_global_mutexpool)
- return;
- qt_global_mutexpool = QMutexPool::instance();
-
-#if defined (Q_OS_WIN)
- qt_create_tls();
-#endif
-}
-
-
-/*! \internal
- Cleans up the QThread system.
-*/
-void QThread::cleanup()
-{
- qt_global_mutexpool = 0;
-}
-
/*! \fn void QThread::setPriority(Priority priority)
\since 4.1
@@ -658,11 +630,11 @@ QThread::Priority QThread::priority() const
Blocks the thread until either of these conditions is met:
\list
- \o The thread associated with this QThread object has finished
+ \li The thread associated with this QThread object has finished
execution (i.e. when it returns from \l{run()}). This function
will return true if the thread has finished. It also returns
true if the thread has not been started yet.
- \o \a time milliseconds has elapsed. If \a time is ULONG_MAX (the
+ \li \a time milliseconds has elapsed. If \a time is ULONG_MAX (the
default), then the wait will never timeout (the thread must
return from \l{run()}). This function will return false if the
wait timed out.
diff --git a/src/corelib/thread/qthread.h b/src/corelib/thread/qthread.h
index ba119afb5d..953632c6fc 100644
--- a/src/corelib/thread/qthread.h
+++ b/src/corelib/thread/qthread.h
@@ -128,9 +128,6 @@ private:
Q_OBJECT
Q_DECLARE_PRIVATE(QThread)
- static void initialize();
- static void cleanup();
-
friend class QCoreApplication;
friend class QThreadData;
};
diff --git a/src/corelib/thread/qthread_unix.cpp b/src/corelib/thread/qthread_unix.cpp
index d458ee9472..a0913e5dbc 100644
--- a/src/corelib/thread/qthread_unix.cpp
+++ b/src/corelib/thread/qthread_unix.cpp
@@ -287,7 +287,7 @@ void *QThreadPrivate::start(void *arg)
else
createEventDispatcher(data);
-#if !defined(QT_NO_DEBUG) && (defined(Q_OS_LINUX) || defined(Q_OS_MAC))
+#if (defined(Q_OS_LINUX) || defined(Q_OS_MAC))
// sets the name of the current thread.
QByteArray objectName = thr->objectName().toLocal8Bit();
diff --git a/src/corelib/thread/qthreadpool.cpp b/src/corelib/thread/qthreadpool.cpp
index af8c99197e..b7021817c5 100644
--- a/src/corelib/thread/qthreadpool.cpp
+++ b/src/corelib/thread/qthreadpool.cpp
@@ -308,31 +308,6 @@ bool QThreadPoolPrivate::waitForDone(int msecs)
}
/*! \internal
- Pulls a runnable from the front queue and runs it in the current thread. Blocks
- until the runnable has completed. Returns true if a runnable was found.
-*/
-bool QThreadPoolPrivate::startFrontRunnable()
-{
- QMutexLocker locker(&mutex);
- if (queue.isEmpty())
- return false;
-
- QRunnable *runnable = queue.takeFirst().first;
- const bool autoDelete = runnable->autoDelete();
- bool del = autoDelete && !--runnable->ref;
-
- locker.unlock();
- runnable->run();
- locker.relock();
-
- if (del) {
- delete runnable;
- }
-
- return true;
-}
-
-/*! \internal
Seaches for \a runnable in the queue, removes it from the queue and
runs it if found. This functon does not return until the runnable
has completed.
diff --git a/src/corelib/thread/qthreadpool_p.h b/src/corelib/thread/qthreadpool_p.h
index 9a7c09695f..910e0b0714 100644
--- a/src/corelib/thread/qthreadpool_p.h
+++ b/src/corelib/thread/qthreadpool_p.h
@@ -83,7 +83,6 @@ public:
void startThread(QRunnable *runnable = 0);
void reset();
bool waitForDone(int msecs = -1);
- bool startFrontRunnable();
void stealRunnable(QRunnable *);
mutable QMutex mutex;
diff --git a/src/corelib/thread/qthreadstorage.cpp b/src/corelib/thread/qthreadstorage.cpp
index 1dfa3305bc..68db8fe261 100644
--- a/src/corelib/thread/qthreadstorage.cpp
+++ b/src/corelib/thread/qthreadstorage.cpp
@@ -246,11 +246,11 @@ void QThreadStorageData::finish(void **p)
\list
- \o The QThreadStorage destructor does not delete per-thread data.
+ \li The QThreadStorage destructor does not delete per-thread data.
QThreadStorage only deletes per-thread data when the thread exits
or when setLocalData() is called multiple times.
- \o QThreadStorage can be used to store data for the \c main()
+ \li QThreadStorage can be used to store data for the \c main()
thread. QThreadStorage deletes all data set for the \c main()
thread when QApplication is destroyed, regardless of whether or
not the \c main() thread has actually finished.
diff --git a/src/corelib/thread/qwaitcondition.qdoc b/src/corelib/thread/qwaitcondition.qdoc
index 7b861f8f7a..8c93bd167d 100644
--- a/src/corelib/thread/qwaitcondition.qdoc
+++ b/src/corelib/thread/qwaitcondition.qdoc
@@ -129,9 +129,9 @@
calling thread will block until either of these conditions is met:
\list
- \o Another thread signals it using wakeOne() or wakeAll(). This
+ \li Another thread signals it using wakeOne() or wakeAll(). This
function will return true in this case.
- \o \a time milliseconds has elapsed. If \a time is \c ULONG_MAX
+ \li \a time milliseconds has elapsed. If \a time is \c ULONG_MAX
(the default), then the wait will never timeout (the event
must be signalled). This function will return false if the
wait timed out.
@@ -157,9 +157,9 @@
calling thread will block until either of these conditions is met:
\list
- \o Another thread signals it using wakeOne() or wakeAll(). This
+ \li Another thread signals it using wakeOne() or wakeAll(). This
function will return true in this case.
- \o \a time milliseconds has elapsed. If \a time is \c ULONG_MAX
+ \li \a time milliseconds has elapsed. If \a time is \c ULONG_MAX
(the default), then the wait will never timeout (the event
must be signalled). This function will return false if the
wait timed out.