ThreadWeaver::DestructedState
#include <destructedstate.h>
Public Member Functions | |
DestructedState (QueueSignals *weaver) | |
JobPointer | applyForWork (Thread *th, bool wasBusy) override |
int | currentNumberOfThreads () const override |
void | dequeue () override |
bool | dequeue (const JobPointer &job) override |
void | enqueue (const QList< JobPointer > &job) override |
void | finish () override |
bool | isEmpty () const override |
bool | isIdle () const override |
int | maximumNumberOfThreads () const override |
int | queueLength () const override |
void | requestAbort () override |
void | resume () override |
void | setMaximumNumberOfThreads (int cap) override |
void | shutDown () override |
StateId | stateId () const override |
void | suspend () override |
void | waitForAvailableJob (Thread *th) override |
const Weaver * | weaver () const override |
Weaver * | weaver () override |
Public Member Functions inherited from ThreadWeaver::WeaverImplState | |
WeaverImplState (QueueSignals *weaver) | |
int | currentNumberOfThreads () const override |
void | dequeue () override |
bool | dequeue (const JobPointer &job) override |
void | enqueue (const QList< JobPointer > &jobs) override |
void | finish () override |
bool | isEmpty () const override |
bool | isIdle () const override |
int | maximumNumberOfThreads () const override |
int | queueLength () const override |
void | requestAbort () override |
void | reschedule () override |
void | setMaximumNumberOfThreads (int cap) override |
void | shutDown () override |
const State * | state () const override |
void | waitForAvailableJob (Thread *th) override |
Public Member Functions inherited from ThreadWeaver::State | |
State (QueueSignals *weaver) | |
~State () override | |
virtual void | activated () |
QString | stateName () const |
Public Member Functions inherited from ThreadWeaver::QueueInterface |
Additional Inherited Members | |
Protected Member Functions inherited from ThreadWeaver::WeaverImplState | |
const Weaver * | weaver () const override |
Weaver * | weaver () override |
Protected Member Functions inherited from ThreadWeaver::State |
Detailed Description
DestructedState is only active after the thread have been destroyed by the destructor, but before superclass destructors have finished.
Definition at line 23 of file destructedstate.h.
Constructor & Destructor Documentation
◆ DestructedState()
|
explicit |
Definition at line 15 of file destructedstate.cpp.
Member Function Documentation
◆ applyForWork()
|
override |
Definition at line 92 of file destructedstate.cpp.
◆ currentNumberOfThreads()
|
overridevirtual |
Returns the current number of threads in the inventory.
Implements ThreadWeaver::QueueInterface.
Definition at line 43 of file destructedstate.cpp.
◆ dequeue() [1/2]
|
overridevirtual |
Remove all queued jobs.
All waiting jobs will be dequeued. The semantics are the same as for dequeue(JobInterface).
- See also
- dequeue(JobInterface)
Implements ThreadWeaver::QueueInterface.
Definition at line 57 of file destructedstate.cpp.
◆ dequeue() [2/2]
|
overridevirtual |
Remove a job from the queue.
If the job was queued but not started so far, it is removed from the queue.
You can always call dequeue, it will return true if the job was dequeued. However if the job is not in the queue anymore, it is already being executed, it is too late to dequeue, and dequeue will return false. The return value is thread-safe - if true is returned, the job was still waiting, and has been dequeued. If not, the job was not waiting in the queue.
Modifying queued jobs is best done on a suspended queue. Often, for example at the end of an application, it is sufficient to dequeue all jobs (which leaves only the ones mid-air in threads), call finish (that will wait for all the mid air jobs to complete), and then exit. Without dequeue(), all jobs in the queue would be executed during finish().
- See also
- requestAbort for aborting jobs during execution
- Returns
- true if the job was waiting and has been dequeued
- false if the job was not found waiting in the queue
Implements ThreadWeaver::QueueInterface.
Definition at line 52 of file destructedstate.cpp.
◆ enqueue()
|
overridevirtual |
Queue a vector of jobs.
It depends on the state if execution of the job will be attempted immediately. In suspended state, jobs can be added to the queue, but the threads remain suspended. In WorkongHard state, an idle thread may immediately execute the job, or it might be queued if all threads are busy.
JobPointer is a shared pointer. This means the object pointed to will be deleted if this object is the last remaining reference to it. Keep a JobPointer to the job to avoid automatic deletion.
Implements ThreadWeaver::QueueInterface.
Definition at line 48 of file destructedstate.cpp.
◆ finish()
|
overridevirtual |
Finish all queued operations, then return.
This method is used in imperative (not event driven) programs that cannot react on events to have the controlling (main) thread wait wait for the jobs to finish. The call will block the calling thread and return when all queued jobs have been processed.
Warning: This will suspend your thread! Warning: If one of your jobs enters an infinite loop, this will never return!
Implements ThreadWeaver::QueueInterface.
Definition at line 61 of file destructedstate.cpp.
◆ isEmpty()
|
overridevirtual |
Is the queue empty? The queue is empty if no more jobs are queued.
Implements ThreadWeaver::QueueInterface.
Definition at line 65 of file destructedstate.cpp.
◆ isIdle()
|
overridevirtual |
Is the weaver idle? The weaver is idle if no jobs are queued and no jobs are processed by the threads.
Implements ThreadWeaver::QueueInterface.
Definition at line 70 of file destructedstate.cpp.
◆ maximumNumberOfThreads()
|
overridevirtual |
Get the maximum number of threads this Weaver may start.
Implements ThreadWeaver::QueueInterface.
Definition at line 38 of file destructedstate.cpp.
◆ queueLength()
|
overridevirtual |
Returns the number of pending jobs.
This will return the number of queued jobs. Jobs that are currently being executed are not part of the queue. All jobs in the queue are waiting to be executed.
Implements ThreadWeaver::QueueInterface.
Definition at line 75 of file destructedstate.cpp.
◆ requestAbort()
|
overridevirtual |
Request aborts of the currently executed jobs.
It is important to understand that aborts are requested, but cannot be guaranteed, as not all Job classes support it. It is up to the application to decide if and how job aborts are necessary.
Implements ThreadWeaver::QueueInterface.
Definition at line 80 of file destructedstate.cpp.
◆ resume()
|
overridevirtual |
Resume job queueing.
- See also
- suspend
Implements ThreadWeaver::QueueInterface.
Definition at line 88 of file destructedstate.cpp.
◆ setMaximumNumberOfThreads()
|
overridevirtual |
Set the maximum number of threads this Weaver object may start.
Implements ThreadWeaver::QueueInterface.
Definition at line 34 of file destructedstate.cpp.
◆ shutDown()
|
overridevirtual |
Shut down the queue.
Tells all threads to exit, and changes to Destructed state. It is safe to destroy the queue once this method returns.
Implements ThreadWeaver::QueueInterface.
Definition at line 20 of file destructedstate.cpp.
◆ stateId()
|
overridevirtual |
◆ suspend()
|
overridevirtual |
Suspend job execution.
When suspending, all threads are allowed to finish the currently assigned job but will not receive a new assignment. When all threads are done processing the assigned job, the signal suspended will() be emitted. If you call suspend() and there are no jobs left to be done, you will immediately receive the suspended() signal.
Implements ThreadWeaver::QueueInterface.
Definition at line 84 of file destructedstate.cpp.
◆ waitForAvailableJob()
|
override |
Definition at line 99 of file destructedstate.cpp.
◆ weaver() [1/2]
|
overridevirtual |
Reimplemented from ThreadWeaver::State.
Definition at line 29 of file destructedstate.cpp.
◆ weaver() [2/2]
|
overridevirtual |
The Weaver interface this state handles.
Reimplemented from ThreadWeaver::State.
Definition at line 24 of file destructedstate.cpp.
The documentation for this class was generated from the following files:
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:09:39 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.