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);
static ThreadWeaver::Queue * instance()
Access the application-global Queue.
Definition: queue.cpp:152
Interface for the global queue factory.
Definition: queue.h:69
T * loadAcquire() const const
QCA_EXPORT void init()
T * loadRelaxed() const const
QueueStream implements a stream based API to access ThreadWeaver queues.
Definition: queuestream.h:21
QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
QThread * thread() const const
int currentNumberOfThreads() const override
Returns the current number of threads in the inventory.
Definition: queue.cpp:222
void enqueue(const QList< JobPointer > &jobs) override
Queue a vector of jobs.
Definition: queue.cpp:167
QCoreApplication * instance()
QueueSignals declares the Qt signals shared by the Queue and Weaver classes.
Definition: queuesignals.h:23
We use a State pattern to handle the system state in ThreadWeaver.
Definition: state.h:55
void setMaximumNumberOfThreads(int cap) override
Set the maximum number of threads this Weaver object may start.
Definition: queue.cpp:217
bool isEmpty() const override
Is the queue empty? The queue is empty if no more jobs are queued.
Definition: queue.cpp:202
void setObjectName(const QString &name)
void setParent(QObject *parent)
int maximumNumberOfThreads() const override
Get the maximum number of threads this Weaver may start.
Definition: queue.cpp:227
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
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Sun Jun 4 2023 04:02:15 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006
Documentation copyright © 1996-2023 The KDE developers.
Generated on Sun Jun 4 2023 04:02:15 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.