ThreadWeaver::State Class

class ThreadWeaver::State

We use a State pattern to handle the system state in ThreadWeaver. More...

Header: #include <ThreadWeaver/State>
CMake: find_package(KF6 REQUIRED COMPONENTS ThreadWeaver)
target_link_libraries(mytarget PRIVATE KF6::ThreadWeaver)
Inherits: ThreadWeaver::QueueInterface and ThreadWeaver::WeaverInterface

Public Functions

State(ThreadWeaver::QueueSignals *weaver)
virtual ~State() override
virtual void activated()
virtual ThreadWeaver::StateId stateId() const = 0
QString stateName() const

Protected Functions

virtual ThreadWeaver::QueueInterface *weaver()
virtual const ThreadWeaver::QueueInterface *weaver() const
enum StateId { InConstruction, WorkingHard, Suspending, Suspended, ShuttingDown, …, NoOfStates }

Detailed Description

Member Function Documentation

[explicit] State::State(ThreadWeaver::QueueSignals *weaver)

Default constructor.

[override virtual noexcept] State::~State()

Destructor.

[virtual] void State::activated()

The state has been changed so that this object is responsible for state handling.

[pure virtual] ThreadWeaver::StateId State::stateId() const

The state Id.

QString State::stateName() const

The ID of the current state.

See also StateID.

[virtual protected] ThreadWeaver::QueueInterface *State::weaver()

The Weaver interface this state handles.

[virtual protected] const ThreadWeaver::QueueInterface *State::weaver() const

Related Non-Members

enum StateId

All weaver objects maintain a state of operation which can be queried by the application. See the threadweaver documentation on how the different states are related.

ConstantValueDescription
ThreadWeaver::State::InConstruction0The object is in the state of construction and has not yet started to process jobs.
ThreadWeaver::State::WorkingHard1Jobs are being processed.
ThreadWeaver::State::Suspending2Job processing is suspended, but some jobs which where already in progress are not finished yet.
ThreadWeaver::State::Suspended3Job processing is suspended, and no jobs are being processed.
ThreadWeaver::State::ShuttingDown4The object is being destructed. Jobs might still be processed, the destructor will wait for all threads to exit and then end.
ThreadWeaver::State::Destructed5The object is being destructed, and all threads have exited. No jobs are handled anymore.
ThreadWeaver::State::NoOfStates6Not a state, but a sentinel for the number of defined states.