xentara-plugin v1.2.1
The Xentara Plugin Framework
Loading...
Searching...
No Matches
xentara::process::Task Class Referenceabstract

A task that needs to performed by a plugin. More...

#include <process/Task.hpp>

+ Inheritance diagram for xentara::process::Task:

Public Types

enum class  Timing { RealTime , RealTimeCompatible , Conventional }
 The timing contraints of the task. More...
 
enum class  Stage {
  Startup , PreOperational , Operational , PostOperational ,
  Shutdown , Suspended , Terminated , internal
}
 The operational stages of Xentara. More...
 
enum class  Status { Pending , Ready , Completed }
 The status a task within an operational stage. More...
 
using Stages = utils::core::Flags< Stage >
 A combination of operational stages.
 

Public Member Functions

virtual ~Task ()=0
 Virtual destructor.
 
virtual auto timing () const -> Timing
 Called by the framework to get the timing requirements.
 
virtual auto stages () const -> Stages
 Called by the framework to determine which stages the task implements.
 
virtual auto schedule (const Track &track, std::optional< TimerSchedule > timerSchedule) -> void
 Called by the framework when the task is scheduled in an execution pipeline.
 
virtual auto prepareStartup (const ExecutionContext &context) -> Status
 Called by the framework once at the beginning of the startup stage.
 
virtual auto startup (const ExecutionContext &context) -> Status
 Called by the framework to perform the startup stage.
 
virtual auto preparePreOperational (const ExecutionContext &context) -> Status
 Called by the framework once at the beginning of the pre-operational stage.
 
virtual auto preOperational (const ExecutionContext &context) -> Status
 Called by the framework to perform the pre-operational stage.
 
virtual auto operational (const ExecutionContext &context) -> void=0
 Called by the framework to perform the operational stage.
 
virtual auto preparePostOperational (const ExecutionContext &context) -> Status
 Called by the framework once at the beginning of the post-operational stage.
 
virtual auto postOperational (const ExecutionContext &context) -> Status
 Called by the framework to perform the post-operational stage.
 
virtual auto prepareShutdown (const ExecutionContext &context) -> Status
 Called by the framework once at the beginning of the shutdown stage.
 
virtual auto shutdown (const ExecutionContext &context) -> Status
 Called by the framework to perform the shutdown stage.
 
- Public Member Functions inherited from xentara::utils::tools::DisableCopy
constexpr DisableCopy () noexcept=default
 
 DisableCopy (const DisableCopy &)=delete
 
DisableCopyoperator= (const DisableCopy &)=delete
 

Static Public Attributes

Standard Names
static const std::string_view kReconnect
 The standard name for the reconnect task of an I/O component.
 

Detailed Description

A task that needs to performed by a plugin.

See also
Publishing Tasks
Tasks in the Xentara user manual

Member Typedef Documentation

◆ Stages

A combination of operational stages.

Member Enumeration Documentation

◆ Stage

enum class xentara::process::Task::Stage
strong

The operational stages of Xentara.

Enumerator
Startup 

The startup stage. This stage is executed when Xentara starts up.

PreOperational 

The pre-operational stage. This stage is executed after the startup stage, and when a paused workload is restarted.

Operational 

The operational stage. This stage is executed while the workload is running.

PostOperational 

This stage is executed before the shutdown stage, and when a workload is suspended.

Shutdown 

This stage is executed once on Xentara shutdown.

Suspended 

This stage denotes that a workload has been suspended. No operation takes place in the suspended stage.

Terminated 

This is a pseudo-stage denotes that Xentara has terminated completely.

◆ Status

enum class xentara::process::Task::Status
strong

The status a task within an operational stage.

Enumerator
Pending 

The task has not yet completed the work it needs to do in this stage.

    A task should return this status if it needs to be executed again to finish the work for this stage.
    Xentara will remain in the current stage, and the task will be executed again once an event or a timer
    it is attached to is triggered. 
Ready 

The task has completed the work it needs to do in this stage, but still wants to be executed.

    A task should return this status if it has completed all the work necessary to finish the stage, but 
    needs to be executed while other tasks complete their work. The task will keep being executed 
    whenever an event or a timer it is attached to is triggered, until all tasks in all tracks have finished their
    work for this stage.
    @note It is not possible to go back to the pending state once a task has returned this status. Once a 
    task has returned \a Ready for a certain stage, returning \a Pending later in the same stage
    has no effect. The stage will remain completed, but the task will be executed again as if it has returned
    \a Ready. 
Completed 

The task has completely finished the work it needs to do in this stage.

    A task should return this status if it has completed all the work it needs to do for this stage, and
    doesn't have to be called again for this stage. 

◆ Timing

enum class xentara::process::Task::Timing
strong

The timing contraints of the task.

Enumerator
RealTime 

The task must be executed as a real-time task.

RealTimeCompatible 

The task can be executed as a real-time task, but need not.

Conventional 

The task cannot be executed as a real-time task.

Constructor & Destructor Documentation

◆ ~Task()

xentara::process::Task::~Task ( )
pure virtualdefault

Virtual destructor.

Member Function Documentation

◆ operational()

virtual auto xentara::process::Task::operational ( const ExecutionContext context) -> void
pure virtual

Called by the framework to perform the operational stage.

Parameters
contextA context that allows access to time stamps, counters, etc.

◆ postOperational()

virtual auto xentara::process::Task::postOperational ( const ExecutionContext context) -> Status
virtual

Called by the framework to perform the post-operational stage.

Default Implementation
The default implementation returns Status::Completed.
Parameters
contextA context that allows access to time stamps, counters, etc.
Returns
The execution status for the current stage.

Reimplemented in xentara::process::StageAgnosticTask.

◆ preOperational()

virtual auto xentara::process::Task::preOperational ( const ExecutionContext context) -> Status
virtual

Called by the framework to perform the pre-operational stage.

Default Implementation
The default implementation returns Status::Completed.
Parameters
contextA context that allows access to time stamps, counters, etc.
Returns
The execution status for the current stage.

Reimplemented in xentara::process::StageAgnosticTask.

◆ preparePostOperational()

virtual auto xentara::process::Task::preparePostOperational ( const ExecutionContext context) -> Status
virtual

Called by the framework once at the beginning of the post-operational stage.

Default Implementation
The default implementation returns Status::Pending.
Parameters
contextA context that allows access to time stamps, counters, etc.
Returns
The execution status for the current stage.

Reimplemented in xentara::process::StageAgnosticTask.

◆ preparePreOperational()

virtual auto xentara::process::Task::preparePreOperational ( const ExecutionContext context) -> Status
virtual

Called by the framework once at the beginning of the pre-operational stage.

Default Implementation
The default implementation returns Status::Pending.
Parameters
contextA context that allows access to time stamps, counters, etc.
Returns
The execution status for the current stage.

Reimplemented in xentara::process::StageAgnosticTask.

◆ prepareShutdown()

virtual auto xentara::process::Task::prepareShutdown ( const ExecutionContext context) -> Status
virtual

Called by the framework once at the beginning of the shutdown stage.

Default Implementation
The default implementation returns Status::Pending.
Parameters
contextA context that allows access to time stamps, counters, etc.
Returns
The execution status for the current stage.

Reimplemented in xentara::process::StageAgnosticTask.

◆ prepareStartup()

virtual auto xentara::process::Task::prepareStartup ( const ExecutionContext context) -> Status
virtual

Called by the framework once at the beginning of the startup stage.

Default Implementation
The default implementation returns Status::Pending.
Parameters
contextA context that allows access to time stamps, counters, etc.
Returns
The execution status for the current stage.

Reimplemented in xentara::process::StageAgnosticTask.

◆ schedule()

virtual auto xentara::process::Task::schedule ( const Track &  track,
std::optional< TimerSchedule timerSchedule 
) -> void
virtual

Called by the framework when the task is scheduled in an execution pipeline.

Note
This function may be called multiple times of the task is added to multiples timers and/or event.
Default Implementation
The default implementation does nothing.
Parameters
trackThe track that the pipeline belongs to. This is an opaque reference, but its address can be used to identify the track that the task is being scheduled to. This is useful, e.g., to check whether two tasks have been scheduled to run in different tracks, or whether the same task is being scheduled to more than one track.
timerScheduleThe schedule of the timer, or std::nullopt if the task is being added to an event.
Exceptions
std::exceptionAn exception of this type can be thrown if the scheduling is not acceptable. You can throw an exception of this type if two tasks that need to be in the same track are scheduled in different tracks.

◆ shutdown()

virtual auto xentara::process::Task::shutdown ( const ExecutionContext context) -> Status
virtual

Called by the framework to perform the shutdown stage.

Default Implementation
The default implementation returns Status::Completed.
Parameters
contextA context that allows access to time stamps, counters, etc.
Returns
The execution status for the current stage.

Reimplemented in xentara::process::StageAgnosticTask.

◆ stages()

virtual auto xentara::process::Task::stages ( ) const -> Stages
virtual

Called by the framework to determine which stages the task implements.

The flags for Stage::Operational, Stage::Suspended, and Stage::Terminated are ignored. All tasks are required to implement the operational stage, and the suspended and terminated stages cannot be implemented.

Default Implementation
The default implementation returns Stage::Operational.

Reimplemented in xentara::process::StageAgnosticTask.

◆ startup()

virtual auto xentara::process::Task::startup ( const ExecutionContext context) -> Status
virtual

Called by the framework to perform the startup stage.

Default Implementation
The default implementation returns Status::Completed.
Parameters
contextA context that allows access to time stamps, counters, etc.
Returns
The execution status for the current stage.

Reimplemented in xentara::process::StageAgnosticTask.

◆ timing()

virtual auto xentara::process::Task::timing ( ) const -> Timing
virtual

Called by the framework to get the timing requirements.

Default Implementation
The default implementation returns Timing::Conventional.

Member Data Documentation

◆ kReconnect

const std::string_view xentara::process::Task::kReconnect
static

The standard name for the reconnect task of an I/O component.