My Project
 All Classes Functions Variables Pages
Public Member Functions | Static Public Member Functions | List of all members
Task Class Referenceabstract

Encapsulate a runnable task. More...

#include <Task.h>

Inheritance diagram for Task:
HttpServerTask PubSubClientTask WebSocketReader

Public Member Functions

 Task (std::string taskName="Task", uint16_t stackSize=10000, uint8_t priority=5)
 Create an instance of the task class. More...
 
void setStackSize (uint16_t stackSize)
 Set the stack size of the task. More...
 
void setPriority (uint8_t priority)
 Set the priority of the task. More...
 
void setName (std::string name)
 Set the name of the task. More...
 
void setCore (BaseType_t coreId)
 Set the core number the task has to be executed on. If the core number is not set, tskNO_AFFINITY will be used. More...
 
void start (void *taskData=nullptr)
 Start an instance of the task. More...
 
void stop ()
 Stop the task. More...
 
virtual void run (void *data)=0
 Body of the task to execute. More...
 

Static Public Member Functions

static void delay (int ms)
 Suspend the task for the specified milliseconds. More...
 

Detailed Description

Encapsulate a runnable task.

This class is designed to be subclassed with the method:

void run(void *data) { ... }

For example:

class CurlTestTask : public Task {
void run(void *data) {
// Do something
}
};

implemented.

Constructor & Destructor Documentation

Task::Task ( std::string  taskName = "Task",
uint16_t  stackSize = 10000,
uint8_t  priority = 5 
)

Create an instance of the task class.

Parameters
[in]taskNameThe name of the task to create.
[in]stackSizeThe size of the stack.
Returns
N/A.

Member Function Documentation

void Task::delay ( int  ms)
static

Suspend the task for the specified milliseconds.

Parameters
[in]msThe delay time in milliseconds.
Returns
N/A.
virtual void Task::run ( void *  data)
pure virtual

Body of the task to execute.

This function must be implemented in the subclass that represents the actual task to run. When a task is started by calling start(), this is the code that is executed in the newly created task.

Parameters
[in]dataThe data passed in to the newly started task.
void Task::setCore ( BaseType_t  coreId)

Set the core number the task has to be executed on. If the core number is not set, tskNO_AFFINITY will be used.

Parameters
[in]coreIdThe id of the core.
Returns
N/A.
void Task::setName ( std::string  name)

Set the name of the task.

Parameters
[in]nameThe name for the task.
Returns
N/A.
void Task::setPriority ( uint8_t  priority)

Set the priority of the task.

Parameters
[in]priorityThe priority for the task.
Returns
N/A.
void Task::setStackSize ( uint16_t  stackSize)

Set the stack size of the task.

Parameters
[in]stackSizeThe size of the stack for the task.
Returns
N/A.
void Task::start ( void *  taskData = nullptr)

Start an instance of the task.

Parameters
[in]taskDataData to be passed into the task.
Returns
N/A.
void Task::stop ( )

Stop the task.

Returns
N/A.

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