TaskManagerIO
Loading...
Searching...
No Matches
TimerTask Class Reference

#include <TaskTypes.h>

Public Member Functions

unsigned long microsFromNow ()
void initialise (sched_t when, TimerUnit unit, TimerFn execCallback, bool repeating)
void initialise (sched_t when, TimerUnit unit, Executable *executable, bool deleteWhenDone, bool repeating)
void initialiseEvent (BaseEvent *event, bool deleteWhenDone)
void handleScheduling (sched_t when, TimerUnit unit, bool repeating)
bool isInUse ()
bool isRepeating () const
void clear ()
bool allocateIfPossible ()
void markRunning ()
void clearRunning ()
bool isRunning () const
bool isEvent ()
TimerTaskgetNext ()
void setNext (TimerTask *nextTask)
void execute ()
void processEvent ()
bool isMicrosSchedule ()
bool isMillisSchedule ()
bool isEnabled ()
void setEnabled (bool ena)

Detailed Description

Internal class that represents a single task slot. You should never have to deal with this class in user code.

Represents a single task or event that will be processed at some point in time. It stores the last evaluation time and also the execution parameters. EG execute every 100 millis.

Member Function Documentation

◆ microsFromNow()

unsigned long TimerTask::microsFromNow ( )
Returns
the number of microseconds before execution is to take place, 0 means it's due or past due.

◆ initialise() [1/2]

void TimerTask::initialise ( sched_t when,
TimerUnit unit,
TimerFn execCallback,
bool repeating )

Initialise a task slot with execution information

Parameters
executionInfothe time of execution
unitthe unit of time measurement
execCallbackthe function to call back

◆ initialise() [2/2]

void TimerTask::initialise ( sched_t when,
TimerUnit unit,
Executable * executable,
bool deleteWhenDone,
bool repeating )

Initialise a task slot with execution information

Parameters
executionInfothe time of execution
unitthe unit of time measurement
executablethe class instance to call back
deleteWhenDoneindicates taskmanager owns this memory and should delete it when clear is called.

◆ initialiseEvent()

void TimerTask::initialiseEvent ( BaseEvent * event,
bool deleteWhenDone )

Initialise an event structure, which will call the event immediately to get the next poll time

Parameters
eventthe event object reference
deleteWhenDoneif task manager owns it, if true, it will be deleted when clear is called.

◆ handleScheduling()

void TimerTask::handleScheduling ( sched_t when,
TimerUnit unit,
bool repeating )

Called by all the initialise methods to actually do the initial scheduling.

Parameters
whenwhen the task is to take place.
unitthe time unit upon which it will occur.

◆ isInUse()

bool TimerTask::isInUse ( )
inline

Atomically checks if the task is in use at the moment.

Returns
true if in use, otherwise false.

◆ isRepeating()

bool TimerTask::isRepeating ( ) const

Checks if this task is a repeating task.

Returns
true if repeating, otherwise false.

◆ clear()

void TimerTask::clear ( )

Take a task out of use and clear down all it's fields. Clears the in use flag last for thread safety

◆ allocateIfPossible()

bool TimerTask::allocateIfPossible ( )
inline

Checks if it is possible to allocaate this task, IE that it is presently not in use.

Returns
true if it can be allocated, otherwise false

◆ markRunning()

void TimerTask::markRunning ( )
inline

Marks the task as in a running condition, this prevents the task being re-entered if it yields.

◆ clearRunning()

void TimerTask::clearRunning ( )
inline

Clears the running state of the task, thus allowing it to be scheduled again.

◆ isRunning()

bool TimerTask::isRunning ( ) const
inline
Returns
true if the task is running at the moment, otherwise false. See above running flag methods.

◆ isEvent()

bool TimerTask::isEvent ( )
inline
Returns
true if this timer is representing an event class, otherwise false

◆ getNext()

TimerTask * TimerTask::getNext ( )
inline

Task manager holds a linked list of TimerTask, linked by the next field. It is atomically referenced

Returns
the next task in the linked list

◆ setNext()

void TimerTask::setNext ( TimerTask * nextTask)
inline

Task manager holds a linked list of TimerTask, linked by the next field. It is atomically referenced

Parameters
nextTaskthe new next pointer

◆ execute()

void TimerTask::execute ( )

actually does the execution of the task, or in the case of an event, it runs through the processEvent method.

◆ processEvent()

void TimerTask::processEvent ( )

This method processes an event in full.

  • If it is triggered it executes it
  • If it is complete, it clears it
  • Otherwise it calls timeOfNextCheck and reschedules it.

◆ isMicrosSchedule()

bool TimerTask::isMicrosSchedule ( )
inline
Returns
true if the task is on a microsecond schedule

◆ isMillisSchedule()

bool TimerTask::isMillisSchedule ( )
inline
Returns
true if the task in on a millisecond schedule

◆ isEnabled()

bool TimerTask::isEnabled ( )
inline
Returns
if the task is presently enabled - IE it is being scheduled.

◆ setEnabled()

void TimerTask::setEnabled ( bool ena)
inline

Set the task aspi either enabled or disabled. When enabled it is scheduled, otherwise it is not scheduled.

Parameters
enathe enablement status

The documentation for this class was generated from the following files: