summaryrefslogtreecommitdiffstats
path: root/src/corelib/thread/qthreadpool.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib/thread/qthreadpool.cpp')
-rw-r--r--src/corelib/thread/qthreadpool.cpp37
1 files changed, 26 insertions, 11 deletions
diff --git a/src/corelib/thread/qthreadpool.cpp b/src/corelib/thread/qthreadpool.cpp
index 6d258af9df0..b1f538fa431 100644
--- a/src/corelib/thread/qthreadpool.cpp
+++ b/src/corelib/thread/qthreadpool.cpp
@@ -163,7 +163,7 @@ void QThreadPoolThread::registerThreadInactive()
/*
\internal
*/
-QThreadPoolPrivate:: QThreadPoolPrivate()
+QThreadPoolPrivate::QThreadPoolPrivate()
{ }
bool QThreadPoolPrivate::tryStart(QRunnable *task)
@@ -223,10 +223,8 @@ void QThreadPoolPrivate::enqueueTask(QRunnable *runnable, int priority)
int QThreadPoolPrivate::activeThreadCount() const
{
- return (allThreads.count()
- - expiredThreads.count()
- - waitingThreads.count()
- + reservedThreads);
+ return int(allThreads.count() - expiredThreads.count() - waitingThreads.count()
+ + reservedThreads);
}
void QThreadPoolPrivate::tryToStartMoreThreads()
@@ -605,11 +603,15 @@ int QThreadPool::expiryTimeout() const
void QThreadPool::setExpiryTimeout(int expiryTimeout)
{
Q_D(QThreadPool);
- if (d->expiryTimeout == expiryTimeout)
- return;
d->expiryTimeout = expiryTimeout;
}
+QBindable<int> QThreadPool::bindableExpiryTimeout()
+{
+ Q_D(QThreadPool);
+ return &d->expiryTimeout;
+}
+
/*! \property QThreadPool::maxThreadCount
\brief the maximum number of threads used by the thread pool.
@@ -631,11 +633,18 @@ void QThreadPool::setMaxThreadCount(int maxThreadCount)
Q_D(QThreadPool);
QMutexLocker locker(&d->mutex);
- if (maxThreadCount == d->maxThreadCount)
- return;
-
+ const auto maxThreadCountChanged = maxThreadCount != d->maxThreadCount;
+ // Rewrite the value in any case, to make sure the binding is cleared.
d->maxThreadCount = maxThreadCount;
- d->tryToStartMoreThreads();
+
+ if (maxThreadCountChanged)
+ d->tryToStartMoreThreads();
+}
+
+QBindable<int> QThreadPool::bindableMaxThreadCount()
+{
+ Q_D(QThreadPool);
+ return &d->maxThreadCount;
}
/*! \property QThreadPool::activeThreadCount
@@ -698,6 +707,12 @@ uint QThreadPool::stackSize() const
return d->stackSize;
}
+QBindable<uint> QThreadPool::bindableStackSize()
+{
+ Q_D(QThreadPool);
+ return &d->stackSize;
+}
+
/*!
Releases a thread previously reserved by a call to reserveThread().