23 Q_DECLARE_PRIVATE(QThreadPool)
24 Q_PROPERTY(
int expiryTimeout READ expiryTimeout WRITE setExpiryTimeout)
25 Q_PROPERTY(
int maxThreadCount READ maxThreadCount WRITE setMaxThreadCount)
26 Q_PROPERTY(
int activeThreadCount READ activeThreadCount)
27 Q_PROPERTY(uint stackSize READ stackSize WRITE setStackSize)
28 Q_PROPERTY(QThread::Priority threadPriority READ threadPriority WRITE setThreadPriority)
29 friend class QFutureInterfaceBase;
32 QThreadPool(QObject *parent =
nullptr);
35 static QThreadPool *globalInstance();
37 void start(QRunnable *runnable,
int priority = 0);
38 bool tryStart(QRunnable *runnable);
40#if QT_CORE_REMOVED_SINCE(6
, 6
)
41 void start(std::function<
void()> functionToRun,
int priority = 0);
42 bool tryStart(std::function<
void()> functionToRun);
45 void startOnReservedThread(QRunnable *runnable);
46#if QT_CORE_REMOVED_SINCE(6
, 6
)
47 void startOnReservedThread(std::function<
void()> functionToRun);
50 template <
typename Callable, QRunnable::if_callable<Callable> =
true>
51 void start(Callable &&functionToRun,
int priority = 0);
52 template <
typename Callable, QRunnable::if_callable<Callable> =
true>
53 bool tryStart(Callable &&functionToRun);
54 template <
typename Callable, QRunnable::if_callable<Callable> =
true>
55 void startOnReservedThread(Callable &&functionToRun);
57 int expiryTimeout()
const;
58 void setExpiryTimeout(
int expiryTimeout);
60 int maxThreadCount()
const;
61 void setMaxThreadCount(
int maxThreadCount);
63 int activeThreadCount()
const;
65 void setStackSize(uint stackSize);
66 uint stackSize()
const;
68 void setThreadPriority(QThread::Priority priority);
69 QThread::Priority threadPriority()
const;
74 void setServiceLevel(QThread::QualityOfService serviceLevel);
75 QThread::QualityOfService serviceLevel()
const;
77 QT_CORE_INLINE_SINCE(6, 8)
78 bool waitForDone(
int msecs);
79 bool waitForDone(QDeadlineTimer deadline = QDeadlineTimer::Forever);
83 bool contains(
const QThread *thread)
const;
85 [[nodiscard]]
bool tryTake(QRunnable *runnable);