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
505JobPointer 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()));
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()));
DestructedState is only active after the thread have been destroyed by the destructor,...
Definition destructedstate.h:24
InConstructionState handles the calls to the Weaver object until the constructor has finished.
Definition inconstructionstate.h:25
bool isFinished() const override
Returns true if the jobs's execute method finished.
Definition job.cpp:188
Lambda is a template that takes any type on which operator() is available, and executes it in run().
Definition lambda.h:20
void finished()
Emitted when the Queue has completed all jobs currently queued.
void stateChanged(ThreadWeaver::State *)
Emitted when the processing state of the Queue has changed.
ShuttingDownState is enabled when the Weaver destructor is entered.
Definition shuttingdownstate.h:24
We use a State pattern to handle the system state in ThreadWeaver.
Definition state.h:56
In SuspendedState, jobs are queued, but will not be executed.
Definition suspendedstate.h:22
SuspendingState is the state after suspend() has been called, but before all threads finished executi...
Definition suspendingstate.h:23
void enqueue(const QList< JobPointer > &jobs) override
Queue a vector of jobs.
Definition weaver.cpp:203
void threadEnteredRun(Thread *thread)
Called from a new thread when entering the run method.
Definition weaver.cpp:489
bool isEmpty() const override
Is the queue empty? The queue is empty if no more jobs are queued.
Definition weaver.cpp:334
void threadSuspended(ThreadWeaver::Thread *)
A thread has been suspended.
void blockThreadUntilJobsAreBeingAssigned_locked(Thread *th)
Blocks the calling thread until jobs can be assigned.
Definition weaver.cpp:596
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
void waitForAvailableJob(Thread *th) override
Wait for a job to become available.
Definition weaver.cpp:579
int maximumNumberOfThreads() const override
Get the maximum number of threads this Weaver may start.
Definition weaver.cpp:177
int currentNumberOfThreads() const override
Returns the current number of threads in the inventory.
Definition weaver.cpp:190
void setMaximumNumberOfThreads(int cap) override
Set the maximum number of threads this Weaver object may start.
Definition weaver.cpp:158
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
void threadStarted(ThreadWeaver::Thread *)
A Thread has been created.
void blockThreadUntilJobsAreBeingAssigned(Thread *th)
Blocks the calling thread until jobs can be assigned.
Definition weaver.cpp:585
JobPointer applyForWork(Thread *thread, bool wasBusy) override
Assign a job to the calling thread.
Definition weaver.cpp:573
Q_EMITQ_EMIT
QThread * thread() const const
QThread * currentThread()
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Tue Mar 26 2024 11:14:31 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006
Documentation copyright © 1996-2024 The KDE developers.
Generated on Tue Mar 26 2024 11:14:31 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.