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

#include <workqueue.hpp>

Public Member Functions

 WorkItem (bool freeAfterComplete=false)
 
virtual ~WorkItem ()
 
bool FreeAfterRun ()
 
virtual void Run ()=0
 

Private Attributes

const bool FreeItemAfterCompleted
 

Detailed Description

This class encapsulates the idea of a discrete, non-repeating task. Create a WorkItem when there is something you need to do on a different Thread, but doesn't have to happen periodically. This is a great construct for one off fire and forget tasks.

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

Definition at line 67 of file workqueue.hpp.

Constructor & Destructor Documentation

◆ WorkItem()

WorkItem::WorkItem ( bool  freeAfterComplete = false)

Our constructor.

Parameters
freeAfterCompleteIf you pass in a true, you are requesing the WorkQueue itself to delete this WorkItem after it has run it.
Note
Only set freeAfterComplete = true if: 1) You dynamically allocated it (i.e. used "new") 2) After you call QueueWork() you promise never to touch this object again.

Definition at line 46 of file cworkqueue.cpp.

◆ ~WorkItem()

WorkItem::~WorkItem ( )
virtual

Our destructor.

Definition at line 52 of file cworkqueue.cpp.

Member Function Documentation

◆ FreeAfterRun()

bool WorkItem::FreeAfterRun ( )

Allows a client to decide if this WorkItem is marked for automatic deletion.

Definition at line 57 of file cworkqueue.cpp.

◆ Run()

virtual void cpp_freertos::WorkItem::Run ( )
pure virtual

Implementation of your actual WorkItem function. You must override this function.

Member Data Documentation

◆ FreeItemAfterCompleted

const bool cpp_freertos::WorkItem::FreeItemAfterCompleted
private

Designates whether this WorkItem should be deleted after the WorkQueue has run it.

Definition at line 117 of file workqueue.hpp.


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