summaryrefslogtreecommitdiffstats
path: root/src/corelib/thread/qthreadpool.h
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2021-05-10 17:34:20 +0200
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2021-10-06 14:55:20 +0200
commit733923c81cd313a02976c026484654e4501b3527 (patch)
tree10cf0847b668ab7b17c139b38dc9e0d3e21d9109 /src/corelib/thread/qthreadpool.h
parent2c3617dfcb4a5230f51f2d2b2eac0e1fb26206cd (diff)
Add a safer way to use QThreadPool::reserveThread
Add startOnReservedThread that specifically releases a reserved thread and uses it atomically for a given task. This can make a positive number of reserved threads work. Change-Id: I4bd1dced24bb46fcb365f12cbc9c7905dc66cdf1 Reviewed-by: David Faure <david.faure@kdab.com>
Diffstat (limited to 'src/corelib/thread/qthreadpool.h')
-rw-r--r--src/corelib/thread/qthreadpool.h3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/corelib/thread/qthreadpool.h b/src/corelib/thread/qthreadpool.h
index f3d7e2254b..853055cb30 100644
--- a/src/corelib/thread/qthreadpool.h
+++ b/src/corelib/thread/qthreadpool.h
@@ -75,6 +75,9 @@ public:
void start(std::function<void()> functionToRun, int priority = 0);
bool tryStart(std::function<void()> functionToRun);
+ void startOnReservedThread(QRunnable *runnable);
+ void startOnReservedThread(std::function<void()> functionToRun);
+
int expiryTimeout() const;
void setExpiryTimeout(int expiryTimeout);