ThreadWeaver
queue.cpp
29 Q_ASSERT_X(qApp != nullptr, Q_FUNC_INFO, "Cannot create global ThreadWeaver instance before QApplication!");
63 * If the queue is not already in Destructed state, the destructor will call shutDown() to make sure
91 * Once set, the global queue factory will be deleted when the global ThreadWeaver pool is deleted.
92 * The factory object needs to be set before the global ThreadWeaver pool is instantiated. Call this
113 explicit StaticThreadWeaverInstanceGuard(QAtomicPointer<Queue> &instance, QCoreApplication *app)
117 Q_ASSERT_X(app != nullptr, Q_FUNC_INFO, "Calling ThreadWeaver::Weaver::instance() requires a QCoreApplication!");
145 * In some cases, the global queue is sufficient for the applications purpose. The global queue will only be
149 * The global queue will be destroyed when Q(Core)Application is destructed. After that, the instance() method
154 static QAtomicPointer<Queue> s_instance(globalQueueFactory ? globalQueueFactory->create(qApp) : new Queue(qApp));
156 // When s_instanceGuard is destructed (first, before s_instance), it sets the value of s_instance to zero. Next, qApp will delete
158 static StaticThreadWeaverInstanceGuard *s_instanceGuard = new StaticThreadWeaverInstanceGuard(s_instance, qApp);
virtual bool isEmpty() const =0
Is the queue empty? The queue is empty if no more jobs are queued.
virtual void requestAbort()=0
Request aborts of the currently executed jobs.
virtual void enqueue(const QList< JobPointer > &jobs)=0
Queue a vector of jobs.
virtual bool isIdle() const =0
Is the weaver idle? The weaver is idle if no jobs are queued and no jobs are processed by the threads...
virtual int currentNumberOfThreads() const =0
Returns the current number of threads in the inventory.
virtual void finish()=0
Finish all queued operations, then return.
virtual bool dequeue(const JobPointer &job)=0
Remove a job from the queue.
virtual int maximumNumberOfThreads() const =0
Get the maximum number of threads this Weaver may start.
virtual int queueLength() const =0
Returns the number of pending jobs.
virtual void setMaximumNumberOfThreads(int cap)=0
Set the maximum number of threads this Weaver object may start.
virtual const State * state() const =0
Return the state of the weaver object.
virtual void reschedule()=0
Reschedule the jobs in the queue.
QueueSignals declares the Qt signals shared by the Queue and Weaver classes.
Definition queuesignals.h:24
QueueStream implements a stream based API to access ThreadWeaver queues.
Definition queuestream.h:22
void setMaximumNumberOfThreads(int cap) override
Set the maximum number of threads this Weaver object may start.
Definition queue.cpp:217
int maximumNumberOfThreads() const override
Get the maximum number of threads this Weaver may start.
Definition queue.cpp:227
int currentNumberOfThreads() const override
Returns the current number of threads in the inventory.
Definition queue.cpp:222
bool isEmpty() const override
Is the queue empty? The queue is empty if no more jobs are queued.
Definition queue.cpp:202
bool isIdle() const override
Is the weaver idle? The weaver is idle if no jobs are queued and no jobs are processed by the threads...
Definition queue.cpp:207
static void setGlobalQueueFactory(GlobalQueueFactory *factory)
Set the factory object that will create the global queue.
Definition queue.cpp:94
void enqueue(const QList< JobPointer > &jobs) override
Queue a vector of jobs.
Definition queue.cpp:167
We use a State pattern to handle the system state in ThreadWeaver.
Definition state.h:56
QCA_EXPORT void init()
T * loadAcquire() const const
T * loadRelaxed() const const
QCoreApplication * instance()
QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor)
void setObjectName(QAnyStringView name)
void setParent(QObject *parent)
QThread * thread() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:09:38 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:09:38 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.