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 task& thisTask(
void )
noexcept
236 using event_t = taskEvent&;
351 void *taskData{
nullptr };
352 void *asyncData{
nullptr };
354 void *aObj{
nullptr };
355 queue *aQueue{
nullptr };
356 size_t aQueueCount{ 0UL };
357 char name[ 11 ] =
"";
360 size_t entry{ SIZE_MAX };
366 void setFlags(
const uint32_t xFlags,
const bool value )
noexcept;
367 bool getFlag(
const uint32_t flag )
const noexcept;
368 bool deadLineReached(
void )
const noexcept;
369 trigger queueCheckEvents(
void )
noexcept;
370 static const uint32_t BIT_INIT;
371 static const uint32_t BIT_ENABLED;
372 static const uint32_t BIT_QUEUE_RECEIVER;
373 static const uint32_t BIT_QUEUE_FULL;
374 static const uint32_t BIT_QUEUE_COUNT;
375 static const uint32_t BIT_QUEUE_EMPTY;
376 static const uint32_t BIT_SHUTDOWN;
377 static const uint32_t BIT_REMOVE_REQUEST;
378 static const uint32_t EVENT_FLAGS_MASK;
379 static const uint32_t QUEUE_FLAGS_MASK;
381 void operator=(
task const& ) =
delete;
548 size_t getID(
void )
const noexcept;
The class to interface the OS.
Definition kernel.hpp:83
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
A list-node object (Used internally)
Definition list.hpp:62
A Queue object.
Definition queue.hpp:44
A task node object.
Definition task.hpp:348
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:484
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:462
bool disable(void) noexcept
Put the task into a disabled state.
Definition task.hpp:444
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:592
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:600
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:596
const char * getName(void) const noexcept
Retrieves the task name.
bool suspend(void) noexcept
Put the task into a disabled state.
Definition task.hpp:435
virtual ~task()
Definition task.hpp:386
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:474
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:493
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:453
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:299
void(*)(event_t) taskFcn_t
Pointer to a task callback.
Definition task.hpp:289
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:279
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:291
taskState
An enum that defines the possible task operational states.
Definition task.hpp:247
@ bySchedulingRelease
When the scheduler is released.
@ byQueueReceiver
When there are elements available in the attached queue, the scheduler make a data dequeue (auto-rece...
@ byNoReadyTasks
Only available when the Idle Task is triggered.
@ byQueueFull
When the attached queue is full. A pointer to the queue will be available in the event_t::EventData f...
@ None
To indicate the absence of trigger. Reserved for internal use.
@ byQueueEmpty
When the attached queue is empty. A pointer to the queue will be available in the event_t::EventData ...
@ byNotificationSimple
When the execution chain does, according to a requirement of asynchronous notification event prompted...
@ byTimeElapsed
When the time specified for the task elapsed.
@ byNotificationQueued
When there is a queued notification in the FIFO priority queue. For this trigger, the dispatcher perf...
@ byQueueCount
When the element-count of the attached queue reaches the specified value. A pointer to the queue will...
@ byEventFlags
When any event-flag is set.
@ DISABLED_STATE
In this state, the time events will be discarded. This operational state is available when the ENABLE...
@ ASLEEP_STATE
Task operability is put into a deep doze mode, so the task can not be triggered by the lower preceden...
@ AWAKE_STATE
In this state, the task is conceptually in an alert mode, handling most of the available events....
@ ENABLED_STATE
The task can catch all the events. This operational state is available when the ENABLE bit is set.
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