FreeRTOS C++ Wrappers  1.6.0
C++ interface to FreeRTOS
Public Member Functions | Protected Member Functions | Static Private Member Functions | Private Attributes | List of all members
cpp_freertos::Tasklet Class Referenceabstract

#include <tasklet.hpp>

Public Member Functions

 Tasklet ()
 
virtual ~Tasklet ()
 
bool Schedule (uint32_t parameter, TickType_t CmdTimeout=portMAX_DELAY)
 
bool ScheduleFromISR (uint32_t parameter, BaseType_t *pxHigherPriorityTaskWoken)
 

Protected Member Functions

virtual void Run (uint32_t parameter)=0
 
void CheckForSafeDelete ()
 

Static Private Member Functions

static void TaskletAdapterFunction (void *ref, uint32_t parameter)
 

Private Attributes

SemaphoreHandle_t DtorLock
 

Detailed Description

A FreeRTOS wrapper for its concept of a Pended Function. In Linux, one permutation of this would be a Tasklet, or bottom half processing from an ISR.

This is an abstract base class. To use this, you need to subclass it. All of your Tasklets should be derived from the Tasklet class. Then implement the virtual Run function. This is a similar design to Java threading.

Definition at line 119 of file tasklet.hpp.

Constructor & Destructor Documentation

◆ Tasklet()

Tasklet::Tasklet ( )

Constructor

Note
Do not construct inside an ISR! This includes creating local instances of this object.

Definition at line 46 of file ctasklet.cpp.

◆ ~Tasklet()

Tasklet::~Tasklet ( )
virtual

Destructor

Note
Do not delete inside an ISR! This includes the automatic deletion of local instances of this object when leaving scope.

Definition at line 62 of file ctasklet.cpp.

Member Function Documentation

◆ CheckForSafeDelete()

void Tasklet::CheckForSafeDelete ( )
protected

You must call this in your dtor, to synchronize between being called and being deleted.

Definition at line 67 of file ctasklet.cpp.

◆ Run()

virtual void cpp_freertos::Tasklet::Run ( uint32_t  parameter)
protectedpure virtual

Implementation of your actual tasklet code. You must override this function.

Parameters
parameterValue passed to you from the Schedule() methods.

◆ Schedule()

bool Tasklet::Schedule ( uint32_t  parameter,
TickType_t  CmdTimeout = portMAX_DELAY 
)

Schedule this Tasklet to run.

Parameters
parameterValue passed to your Run method.
CmdTimeoutHow long to wait to send this command to the timer daemon.
Returns
true if this command will be sent to the timer daemon, false if it will not (i.e. timeout).

Definition at line 82 of file ctasklet.cpp.

◆ ScheduleFromISR()

bool Tasklet::ScheduleFromISR ( uint32_t  parameter,
BaseType_t *  pxHigherPriorityTaskWoken 
)

Schedule this Tasklet to run from ISR context. This allows FreeRTOS ISRs to defer processing from the ISR into a task context.

Parameters
parameterValue passed to your Run method.
pxHigherPriorityTaskWokenDid this operation result in a rescheduling event.
Returns
true if this command will be sent to the timer daemon, false if it will not (i.e. timeout).

Definition at line 104 of file ctasklet.cpp.

◆ TaskletAdapterFunction()

void Tasklet::TaskletAdapterFunction ( void *  ref,
uint32_t  parameter 
)
staticprivate

Adapter function that allows you to write a class specific Run() function that interfaces with FreeRTOS. Look at the implementation of the constructors and this code to see how the interface between C and C++ is performed.

Definition at line 74 of file ctasklet.cpp.

Member Data Documentation

◆ DtorLock

SemaphoreHandle_t cpp_freertos::Tasklet::DtorLock
private

Protect against accidental deletion before we were executed.

Definition at line 209 of file tasklet.hpp.


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