20#include "QtCore/qmutex.h"
21#include "QtCore/qthread.h"
22#include "QtCore/qwaitcondition.h"
23#include "QtCore/qthreadpool.h"
24#include "QtCore/qset.h"
25#include "QtCore/qqueue.h"
26#include "private/qobject_p.h"
35 Q_DECLARE_PUBLIC(QThreadPool)
45 QueuePage(QRunnable *runnable,
int pri) : m_priority(pri) { push(runnable); }
51 void push(QRunnable *runnable)
53 Q_ASSERT(runnable !=
nullptr);
56 m_entries[m_lastIndex] = runnable;
61 while (!isFinished() && m_entries[m_firstIndex] ==
nullptr) {
69 QRunnable *runnable = m_entries[m_firstIndex];
77 QRunnable *runnable = first();
81 m_entries[m_firstIndex] =
nullptr;
93 for (
int i = m_firstIndex; i <= m_lastIndex; i++) {
94 if (m_entries[i] == runnable) {
95 m_entries[i] =
nullptr;
96 if (i == m_firstIndex) {
110 int m_firstIndex = 0;
111 int m_lastIndex = -1;
119 void enqueueTask(QRunnable *task,
int priority = 0);
127 {
return qMax(requestedMaxThreadCount, 1); }
bool areAllThreadsActive() const
void deletePageIfFinished(QueuePage *page)
bool tryStart(QRunnable *task)
void enqueueTask(QRunnable *task, int priority=0)
int requestedMaxThreadCount
void tryToStartMoreThreads()
QList< QueuePage * > queue
std::chrono::duration< int, std::milli > expiryTimeout
QThread::QualityOfService serviceLevel
QThread::Priority threadPriority
QWaitCondition noActiveThreads
static void destroyGlobalThreadPool()
QQueue< QThreadPoolThread * > expiredThreads
int activeThreadCount() const
int maxThreadCount() const
QSet< QThreadPoolThread * > allThreads
void startThread(QRunnable *runnable=nullptr)
void stealAndRunRunnable(QRunnable *runnable)
QQueue< QThreadPoolThread * > waitingThreads
bool waitForDone(const QDeadlineTimer &timer)
bool tooManyThreadsActive() const
QThreadPoolPrivate * manager
void registerThreadInactive()
QWaitCondition runnableReady
Combined button and popup list for selecting options.
bool comparePriority(int priority, const QueuePage *p)
QThreadPoolPrivate::QueuePage QueuePage
void push(QRunnable *runnable)
QueuePage(QRunnable *runnable, int pri)
bool tryTake(QRunnable *runnable)