ThreadWeaver
weaver.cpp
57 Q_ASSERT_X(state()->stateId() == Destructed, Q_FUNC_INFO, "shutDown() method was not called before Weaver destructor!");
140 TWDEBUG(2, "WeaverImpl::setState: state changed to \"%s\".\n", newState->stateName().toLatin1().constData());
160 Q_ASSERT_X(cap >= 0, "Weaver Impl", "Thread inventory size has to be larger than or equal to zero.");
255 TWDEBUG(3, "WeaverImpl::dequeue: job %p dequeued, %i jobs left.\n", (void *)job.data(), queueLength_p());
303 TWDEBUG(2, "WeaverImpl::finish: wait timed out, %i jobs left, waking threads.\n", queueLength_p());
497 * The job will be removed from the queue (therefore, take). Only jobs that have no unresolved dependencies
498 * are considered available. If only jobs that depend on other unfinished jobs are in the queue, this method
505 JobPointer Weaver::takeFirstAvailableJobOrSuspendOrWait(Thread *th, bool threadWasBusy, bool suspendIfInactive, bool justReturning)
510 TWDEBUG(3, "WeaverImpl::takeFirstAvailableJobOrWait: trying to assign new job to thread %i (%s state).\n", th->id(), qPrintable(state()->stateName()));
512 "WeaverImpl::takeFirstAvailableJobOrWait: %i active threads, was busy: %s, suspend: %s, assign new job: %s.\n",
567 * This is supposed to be called from the Thread objects in the inventory. Do not call this method from
569 * Returns 0 if the weaver is shutting down, telling the calling thread to finish and exit. If no jobs are
570 * available and shut down is not in progress, the calling thread is suspended until either condition is met.
599 TWDEBUG(4, "WeaverImpl::blockThreadUntilJobsAreBeingAssigned_locked: thread %i blocked (%s state).\n", th->id(), qPrintable(state()->stateName()));
bool isEmpty() const override
Is the queue empty? The queue is empty if no more jobs are queued.
Definition: weaver.cpp:334
bool isFinished() const const
bool isEmpty() const const
int currentNumberOfThreads() const override
Returns the current number of threads in the inventory.
Definition: weaver.cpp:190
int maximumNumberOfThreads() const override
Get the maximum number of threads this Weaver may start.
Definition: weaver.cpp:177
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: weaver.cpp:347
Q_EMITQ_EMIT
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...
void setMaximumNumberOfThreads(int cap) override
Set the maximum number of threads this Weaver object may start.
Definition: weaver.cpp:158
void blockThreadUntilJobsAreBeingAssigned(Thread *th)
Blocks the calling thread until jobs can be assigned.
Definition: weaver.cpp:585
void threadEnteredRun(Thread *thread)
Called from a new thread when entering the run method.
Definition: weaver.cpp:489
InConstructionState handles the calls to the Weaver object until the constructor has finished.
Definition: inconstructionstate.h:24
bool wait(QDeadlineTimer deadline)
QByteArray toLatin1() const const
void threadStarted(ThreadWeaver::Thread *)
A Thread has been created.
void requestAbort() override
Request aborts of the currently executed jobs.
Definition: weaver.cpp:373
JobPointer takeFirstAvailableJobOrSuspendOrWait(Thread *th, bool threadWasBusy, bool suspendIfAllThreadsInactive, bool justReturning)
Take the first available job out of the queue and return it.
Definition: weaver.cpp:505
virtual void setMaximumNumberOfThreads(int cap)=0
Set the maximum number of threads this Weaver object may start.
void moveToThread(QThread *targetThread)
QThread * thread() const const
virtual void enqueue(const QVector< JobPointer > &jobs)=0
Queue a vector of jobs.
void enqueue(const QVector< JobPointer > &jobs) override
Queue a vector of jobs.
Definition: weaver.cpp:203
virtual void activated()
The state has been changed so that this object is responsible for state handling.
Definition: state.cpp:45
JobPointer applyForWork(Thread *thread, bool wasBusy) override
Assign a job to the calling thread.
Definition: weaver.cpp:573
void blockThreadUntilJobsAreBeingAssigned_locked(Thread *th)
Blocks the calling thread until jobs can be assigned.
Definition: weaver.cpp:596
void waitForAvailableJob(Thread *th) override
Wait for a job to become available.
Definition: weaver.cpp:579
ShuttingDownState is enabled when the Weaver destructor is entered.
Definition: shuttingdownstate.h:23
void start(QThread::Priority priority)
virtual bool dequeue(const JobPointer &job)=0
Remove a job from the queue.
void finished()
Emitted when the Queue has completed all jobs currently queued.
QThread * currentThread()
We use a State pattern to handle the system state in ThreadWeaver.
Definition: state.h:55
void threadSuspended(ThreadWeaver::Thread *)
A thread has been suspended.
virtual int maximumNumberOfThreads() const =0
Get the maximum number of threads this Weaver may start.
DestructedState is only active after the thread have been destroyed by the destructor,...
Definition: destructedstate.h:23
const State * state() const override
Return the state of the weaver object.
Definition: weaver.cpp:148
const char * constData() const const
Thread represents a worker thread in a Queue's inventory.
Definition: thread.h:27
void stateChanged(ThreadWeaver::State *)
Emitted when the processing state of the Queue has changed.
SuspendingState is the state after suspend() has been called, but before all threads finished executi...
Definition: suspendingstate.h:22
In SuspendedState, jobs are queued, but will not be executed.
Definition: suspendedstate.h:21
virtual void finish()=0
Finish all queued operations, then return.
virtual int currentNumberOfThreads() const =0
Returns the current number of threads in the inventory.
virtual void requestAbort()=0
Request aborts of the currently executed jobs.
virtual int queueLength() const =0
Returns the number of pending jobs.
virtual bool isEmpty() const =0
Is the queue empty? The queue is empty if no more jobs are queued.
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Thu Dec 7 2023 04:04:07 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006
Documentation copyright © 1996-2023 The KDE developers.
Generated on Thu Dec 7 2023 04:04:07 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.