4#include "include/types.hpp"
5#include "include/timer.hpp"
6#include "include/list.hpp"
7#include "include/queue.hpp"
109 bool FirstCall{
false };
110 bool FirstIteration{
false };
111 bool LastIteration{
false };
113 task* currentTask{
nullptr };
146 return FirstIteration;
158 return LastIteration;
194 trigger Trigger{ trigger::None };
195 bool FirstCall{
false };
196 bool FirstIteration{
false };
197 bool LastIteration{
false };
199 task* currentTask{
nullptr };
200 taskEvent() =
default;
203 virtual ~taskEvent(){}
205 void *TaskData{
nullptr };
206 void *EventData{
nullptr };
207 inline bool firstCall(
void )
const noexcept
211 inline bool firstIteration(
void )
const noexcept
213 return FirstIteration;
215 inline bool lastIteration(
void )
const noexcept
217 return LastIteration;
219 inline trigger getTrigger(
void )
const noexcept
223 inline clock_t startDelay(
void )
const noexcept
227 inline task& self(
void )
noexcept
231 inline const task& self(
void )
const noexcept
235 inline task& thisTask(
void )
noexcept
239 inline const task& thisTask(
void )
const noexcept {
355 class task :
protected node,
private nonCopyable {
358 void *taskData{
nullptr };
359 void *asyncData{
nullptr };
361 void *aObj{
nullptr };
362 queue *aQueue{
nullptr };
363 size_t aQueueCount{ 0UL };
364 char name[ 11 ] =
"";
367 size_t entry{ SIZE_MAX };
373 void setFlags(
const uint32_t xFlags,
const bool value )
noexcept;
374 bool getFlag(
const uint32_t flag )
const noexcept;
375 bool deadLineReached(
void )
const noexcept;
376 trigger queueCheckEvents(
void )
noexcept;
377 static const uint32_t BIT_INIT;
378 static const uint32_t BIT_ENABLED;
379 static const uint32_t BIT_QUEUE_RECEIVER;
380 static const uint32_t BIT_QUEUE_FULL;
381 static const uint32_t BIT_QUEUE_COUNT;
382 static const uint32_t BIT_QUEUE_EMPTY;
383 static const uint32_t BIT_SHUTDOWN;
384 static const uint32_t BIT_REMOVE_REQUEST;
385 static const uint32_t EVENT_FLAGS_MASK;
386 static const uint32_t QUEUE_FLAGS_MASK;
553 size_t getID(
void )
const noexcept;
598 explicit operator
bool() const noexcept {
599 return ( SIZE_MAX != entry ) && (
nullptr ==
getContainer() );
The task argument with all the regarding information of the task execution.
Definition task.hpp:105
bool firstIteration(void) const noexcept
Checks whether the current pass is the first iteration of the task. The value returned by this method...
Definition task.hpp:144
clock_t startDelay(void) const noexcept
return the number of epochs between current system time and point in time when the task was marked as...
Definition task.hpp:177
void * TaskData
Task arguments defined at the time of its creation. (Storage-Pointer)
Definition task.hpp:121
trigger getTrigger(void) const noexcept
Get the event source that triggers the task execution. Possible values are described in the qOS::trig...
Definition task.hpp:164
void * EventData
Associated data of the event. Specific data will reside here according to the event source....
Definition task.hpp:128
bool firstCall(void) const noexcept
Checks whether the task is running for the first time. Can be used for data initialization purposes.
Definition task.hpp:133
bool lastIteration(void) const noexcept
Checks whether the current pass is the last iteration of the task. The value returned by this method ...
Definition task.hpp:156
task & thisTask(void) noexcept
return the current task node being evaluated
Definition task.hpp:184
list * getContainer(void) const noexcept
Get a pointer to the list in which this node is contained.
Definition list.hpp:75
A Queue object.
Definition queue.hpp:44
A task node object.
Definition task.hpp:355
bool awake(void) noexcept
Put the task into a normal operation state. Here the task will be able to catch any kind of events.
Definition task.hpp:489
size_t getID(void) const noexcept
Retrieves the Task ID number.
bool setPriority(const priority_t pValue) noexcept
Set/Change the task priority value.
priority_t getPriority(void) const noexcept
Retrieve the current task priority.
bool setData(void *arg) noexcept
Set the task data.
bool enable(void) noexcept
Put the task into a enabled state.
Definition task.hpp:467
bool disable(void) noexcept
Put the task into a disabled state.
Definition task.hpp:449
bool setTime(const qOS::duration_t tValue) noexcept
Set/Change the Task execution interval.
static const iteration_t PERIODIC
A constant to indicate that the task will run every time its timeout has expired.
Definition task.hpp:604
static const iteration_t SINGLE_SHOT
A constant to indicate that the task will be executed only once after its time has expired.
Definition task.hpp:612
void *const & getBindedObject(void) const noexcept
Retrieves a pointer to the object binded to the task, could be either a state-machine or a command-li...
queue * getQueue(void) noexcept
Retrieves a pointer to the queue attached to the task.
static const iteration_t INDEFINITE
Same as PERIODIC. A constant to indicate that the task will run every time its timeout has expired.
Definition task.hpp:608
const char * getName(void) const noexcept
Retrieves the task name.
bool suspend(void) noexcept
Put the task into a disabled state.
Definition task.hpp:440
virtual ~task()
Definition task.hpp:391
taskState getState(void) const noexcept
Retrieve the task operational state.
bool setState(const taskState s) noexcept
Set the task operational state.
bool asleep(void) noexcept
Put the task into a sleep state. The task can't be triggered by the lower precedence events.
Definition task.hpp:479
void setIterations(const iteration_t iValue) noexcept
Set/Change the number of task iterations.
virtual void activities(event_t e)
bool setName(const char *tName) noexcept
Set the task name.
cycles_t getCycles(void) const noexcept
Retrieve the number of task activations.
bool attachQueue(queue &q, const queueLinkMode mode, const size_t arg=1U) noexcept
Attach a queue to the Task.
bool isEnabled(void) const noexcept
Retrieve the enabled/disabled state.
Definition task.hpp:498
bool setCallback(const taskFcn_t tCallback) noexcept
Set/Change the task callback function.
bool resume(void) noexcept
Put the task into a enabled state.
Definition task.hpp:458
friend class core
Definition task.hpp:356
timeCount_t duration_t
The typedef that specified an time quantity, usually expressed in milliseconds.
Definition clock.hpp:18
timeCount_t clock_t
A unsigned integer to hold ticks count. Epochs counter.
Definition clock.hpp:15
uint32_t taskFlag_t
A 32-bit unsigned integer type to hold the task flags.
Definition task.hpp:306
void(*)(event_t) taskFcn_t
Pointer to a task callback.
Definition task.hpp:296
globalState
An enum to describe the task global states.
Definition task.hpp:86
queueLinkMode
An enum that defines the modes in which a queue can be linked to a task.
Definition task.hpp:286
trigger
An enum with all the possible values for the event_t::getTrigger() method.
Definition task.hpp:23
uint32_t notifier_t
A 32-bit unsigned integer type to hold a notification value.
Definition task.hpp:298
taskState
An enum that defines the possible task operational states.
Definition task.hpp:254
@ SUSPENDED
Definition task.hpp:90
@ UNDEFINED
Definition task.hpp:87
@ WAITING
Definition task.hpp:89
@ READY
Definition task.hpp:88
@ RUNNING
Definition task.hpp:91
@ QUEUE_EMPTY
Definition task.hpp:290
@ QUEUE_RECEIVER
Definition task.hpp:287
@ QUEUE_FULL
Definition task.hpp:288
@ QUEUE_COUNT
Definition task.hpp:289
@ bySchedulingRelease
When the scheduler is released.
Definition task.hpp:76
@ byQueueReceiver
When there are elements available in the attached queue, the scheduler make a data dequeue (auto-rece...
Definition task.hpp:52
@ byNoReadyTasks
Only available when the Idle Task is triggered.
Definition task.hpp:80
@ byQueueFull
When the attached queue is full. A pointer to the queue will be available in the event_t::EventData f...
Definition task.hpp:57
@ None
To indicate the absence of trigger. Reserved for internal use.
Definition task.hpp:27
@ byQueueEmpty
When the attached queue is empty. A pointer to the queue will be available in the event_t::EventData ...
Definition task.hpp:68
@ byNotificationSimple
When the execution chain does, according to a requirement of asynchronous notification event prompted...
Definition task.hpp:45
@ byTimeElapsed
When the time specified for the task elapsed.
Definition task.hpp:31
@ byNotificationQueued
When there is a queued notification in the FIFO priority queue. For this trigger, the dispatcher perf...
Definition task.hpp:38
@ byQueueCount
When the element-count of the attached queue reaches the specified value. A pointer to the queue will...
Definition task.hpp:63
@ byEventFlags
When any event-flag is set.
Definition task.hpp:72
@ DISABLED_STATE
In this state, the time events will be discarded. This operational state is available when the ENABLE...
Definition task.hpp:259
@ ASLEEP_STATE
Task operability is put into a deep doze mode, so the task can not be triggered by the lower preceden...
Definition task.hpp:279
@ AWAKE_STATE
In this state, the task is conceptually in an alert mode, handling most of the available events....
Definition task.hpp:271
@ ENABLED_STATE
The task can catch all the events. This operational state is available when the ENABLE bit is set.
Definition task.hpp:264
STD_TYPE_INT32_T iteration_t
A type to instantiate a variable that hold the number of task iterations.
Definition types.hpp:104
STD_TYPE_UINT32_T cycles_t
A type to instantiate a variable that hold the number of task cycles.
Definition types.hpp:99
STD_TYPE_UINT8_T priority_t
A type to instantiate a variable to hold the priority value of a task.
Definition types.hpp:109
OS/Kernel interfaces.
Definition bytebuffer.hpp:7