ThreadWeaver
WeaverImpl.cpp
Go to the documentation of this file.
419 debug( 0, "--> %4i: %p %s (priority %i, can be executed: %s)\n", index, (void*)m_assignments.at( index ),
#define P_ASSERT(x)
P_ASSERT ensures that error messages occur in the correct order.
Definition: DebuggingAids.h:103
DestructedState is only active after the thread have been destroyed by the destructor,...
Definition: DestructedState.h:44
InConstructionState handles the calls to the WeaverImpl object until the constructor has finished.
Definition: InConstructionState.h:46
A Job is a simple abstraction of an action that is to be executed in a thread context.
Definition: Job.h:66
virtual void aboutToBeDequeued(WeaverInterface *weaver)
This Job is about the be dequeued from the weaver's job queue.
Definition: Job.cpp:161
ShuttingDownState is enabled when the Weaver destructor is entered.
Definition: ShuttingDownState.h:44
We use a State pattern to handle the system state in ThreadWeaver.
Definition: State.h:74
virtual void activated()
The state has been changed so that this object is responsible for state handling.
Definition: State.cpp:74
virtual Job * applyForWork(Thread *th, Job *previous)=0
Assign a job to an idle thread.
virtual void waitForAvailableJob(Thread *th)=0
Wait (by suspending the calling thread) until a job becomes available.
In SuspendedState, jobs are queued, but will not be executed.
Definition: SuspendedState.h:44
SuspendingState is the state after suspend() has been called, but before all threads finished executi...
Definition: SuspendingState.h:45
The class Thread is used to represent the worker threads in the weaver's inventory.
Definition: Thread.h:47
void blockThreadUntilJobsAreBeingAssigned(Thread *th)
Blocks the calling thread until some actor calls assignJobs.
Definition: WeaverImpl.cpp:364
void setMaximumNumberOfThreads(int cap)
Set the maximum number of threads this Weaver object may start.
Definition: WeaverImpl.cpp:149
void threadStarted(ThreadWeaver::Thread *)
A Thread has been created.
bool isEmpty() const
Is the queue empty? The queue is empty if no more jobs are queued.
Definition: WeaverImpl.cpp:293
void waitForAvailableJob(Thread *th)
Wait for a job to become available.
Definition: WeaverImpl.cpp:359
int maximumNumberOfThreads() const
Get the maximum number of threads this Weaver may start.
Definition: WeaverImpl.cpp:156
Job * takeFirstAvailableJob(Job *previous)
Take the first available job out of the queue and return it.
Definition: WeaverImpl.cpp:333
void asyncThreadSuspended(ThreadWeaver::Thread *)
virtual Job * applyForWork(Thread *thread, Job *previous)
Assign a job to the calling thread.
Definition: WeaverImpl.cpp:354
int currentNumberOfThreads() const
Returns the current number of threads in the inventory.
Definition: WeaverImpl.cpp:162
void threadBusy(ThreadWeaver::Thread *, ThreadWeaver::Job *j)
The thread is busy executing job j.
int m_active
The number of jobs that are assigned to the worker threads, but not finished.
Definition: WeaverImpl.h:165
void threadSuspended(ThreadWeaver::Thread *)
A thread has been suspended.
bool isIdle() const
Is the weaver idle? The weaver is idle if no jobs are queued and no jobs are processed by the threads...
Definition: WeaverImpl.cpp:380
void assignJobs()
Schedule enqueued jobs to be executed by idle threads.
Definition: WeaverImpl.cpp:288
QWaitCondition m_jobAvailable
Wait condition all idle or done threads wait for.
Definition: WeaverImpl.h:169
WeaverInterface provides a common interface for weaver implementations.
Definition: WeaverInterface.h:61
void finished()
This signal is emitted when the Weaver has finished ALL currently queued jobs.
void jobDone(ThreadWeaver::Job *)
This signal is emitted when a job is finished.
void stateChanged(ThreadWeaver::State *)
The Weaver's state has changed.
Observers provides signals on some Weaver events that are otherwise only available through objects of...
Definition: WeaverObserver.h:59
Definition: DebuggingAids.h:51
StateId
All weaver objects maintain a state of operation which can be queried by the application.
Definition: State.h:48
@ Suspending
Job processing is suspended, but some jobs which where already in progress are not finished yet.
Definition: State.h:56
@ InConstruction
The object is in the state of construction and has not yet started to process jobs.
Definition: State.h:51
void debug(int severity, const char *cformat,...)
This method prints a text message on the screen, if debugging is enabled.
Definition: DebuggingAids.h:112
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Mon Feb 20 2023 00:00:00 by doxygen 1.9.6 written by Dimitri van Heesch, © 1997-2006
Documentation copyright © 1996-2023 The KDE developers.
Generated on Mon Feb 20 2023 00:00:00 by doxygen 1.9.6 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.