24 Q_DECLARE_PRIVATE(QThreadPool)
25 Q_PROPERTY(
int expiryTimeout READ expiryTimeout WRITE setExpiryTimeout)
26 Q_PROPERTY(
int maxThreadCount READ maxThreadCount WRITE setMaxThreadCount)
27 Q_PROPERTY(
int activeThreadCount READ activeThreadCount)
28 Q_PROPERTY(uint stackSize READ stackSize WRITE setStackSize)
29 Q_PROPERTY(QThread::Priority threadPriority READ threadPriority WRITE setThreadPriority)
30 friend class QFutureInterfaceBase;
33 QThreadPool(QObject *parent =
nullptr);
36 static QThreadPool *globalInstance();
38 void start(QRunnable *runnable,
int priority = 0);
39 bool tryStart(QRunnable *runnable);
41#if QT_CORE_REMOVED_SINCE(6
, 6
)
42 void start(std::function<
void()> functionToRun,
int priority = 0);
43 bool tryStart(std::function<
void()> functionToRun);
46 void startOnReservedThread(QRunnable *runnable);
47#if QT_CORE_REMOVED_SINCE(6
, 6
)
48 void startOnReservedThread(std::function<
void()> functionToRun);
51 template <
typename Callable, QRunnable::if_callable<Callable> =
true>
52 void start(Callable &&functionToRun,
int priority = 0);
53 template <
typename Callable, QRunnable::if_callable<Callable> =
true>
54 bool tryStart(Callable &&functionToRun);
55 template <
typename Callable, QRunnable::if_callable<Callable> =
true>
56 void startOnReservedThread(Callable &&functionToRun);
58 int expiryTimeout()
const;
59 void setExpiryTimeout(
int expiryTimeout);
61 int maxThreadCount()
const;
62 void setMaxThreadCount(
int maxThreadCount);
64 int activeThreadCount()
const;
66 void setStackSize(uint stackSize);
67 uint stackSize()
const;
69 void setThreadPriority(QThread::Priority priority);
70 QThread::Priority threadPriority()
const;
75 void setServiceLevel(QThread::QualityOfService serviceLevel);
76 QThread::QualityOfService serviceLevel()
const;
78 QT_CORE_INLINE_SINCE(6, 8)
79 bool waitForDone(
int msecs);
80 bool waitForDone(QDeadlineTimer deadline = QDeadlineTimer::Forever);
84 bool contains(
const QThread *thread)
const;
86 [[nodiscard]]
bool tryTake(QRunnable *runnable);