FreeRTOS Addons
Loading...
Searching...
No Matches
Public Member Functions | 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
 

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.

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.

◆ ~WorkItem()

WorkItem::~WorkItem ( )
virtual

Our destructor.

Member Function Documentation

◆ FreeAfterRun()

bool WorkItem::FreeAfterRun ( )

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

◆ Run()

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

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


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