Class ReactiveTask#

Inheritance Relationships#

Base Type#

Derived Types#

Class Documentation#

class ReactiveTask : public corail_core::TaskBase#

Allow creation of reactive tasks.

A state machine is used to controle the task excution. see

See also

(ReactiveTaskState) and

See also

(ReactiveTaskTrasition).

Subclassed by corail_core::ServiceTask< MessageT >, corail_core::SubscriptionTask< MessageT >

Public Functions

inline ReactiveTask(const std::string &name, int cpu, int priority, std::chrono::nanoseconds period, std::chrono::nanoseconds jitter, std::function<bool(void)> polling_callback, std::function<void(void)> execution_callback)#

Construct a new Reactive Task object.

The task is created in init state.

Parameters
  • name[in] The name of the task.

  • cpu[in] The cpu on which the task will execute.

  • priority[in] The priority of the task (higher priority first).

  • period[in] The periode of the task.

  • jitter[in] The jitter of the task.

  • polling_callback[in] The function to execute et each periode.

  • execution_callback[in] The function to execute if the polling callback return true.

inline ~ReactiveTask()#
inline std::string get_name()#

Get the name.

Returns

std::string

inline int get_cpu() const#

Get the cpu.

Returns

int

inline int get_priority() const#

Get the priority.

Returns

int

inline std::chrono::nanoseconds get_period() const#

Get the period.

Returns

std::chrono::nanoseconds

inline ReactiveTaskState get_state() const#

Get the state.

Returns

PeriodicTaskState

virtual bool create()#

Trigger the create transition.

Launch the creation of the thread in which the task will execute. Only allowed in init state. -> created

Returns

true If the transition succed

Returns

false Otherwise

virtual bool configure()#

Trigger the configure transition.

Configure the thread priority and cpu. Only allowed in created state. -> configured

Returns

true If the transition succed

Returns

false Otherwise

virtual bool cleanup()#

Trigger the cleanup transition.

Only allowed in configured state. -> created

Returns

true If the transition succed

Returns

false Otherwise

virtual bool start(std::chrono::nanoseconds release)#

Trigger the start transition.

Lauch execution of the task at the asked date. Only allowed in configured state. -> started

Parameters

release[in] The date of the first execution of the callback.

Returns

true If the transition succed

Returns

false Otherwise

virtual bool stop()#

Trigger the stop transition.

Stop the execution of the task. Only allowed in started, running or sleeping states. -> configured

Returns

true If the transition succed

Returns

false Otherwise

virtual bool terminate()#

Trigger the terminate transition.

Will destruct the thread of the task. Only allowed in created state. -> init

Returns

true If the transition succed

Returns

false Otherwises

Corail is free software: you can redistribute it and/or modify it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.