Class PeriodicTask#

Inheritance Relationships#

Base Type#

Class Documentation#

class PeriodicTask : public corail_core::TaskBase#

Allow creation of periodic task.

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

See also

(PeriodicTaskState) and

See also

(PeriodiTaskTrasition).

Public Functions

inline PeriodicTask(const std::string &name, int cpu, int priority, std::chrono::nanoseconds period, std::function<void(void)> callback)#

Construct a new Periodic 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.

  • callback[in] The function to execute at each periode.

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

Get the name object.

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 PeriodicTaskState 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 Otherwise

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.