Helper for FreeRTOS static task management.
More...
#include <static_task.h>
Helper for FreeRTOS static task management.
Stores the TCB in internal RAM and manages the stack buffer with create/destroy methods. Call destroy() and deallocate() from another task: a task cannot free the stack it is still running on.
Definition at line 18 of file static_task.h.
◆ StaticTask() [1/3]
| esphome::StaticTask::StaticTask |
( |
| ) |
|
|
default |
◆ StaticTask() [2/3]
| esphome::StaticTask::StaticTask |
( |
const StaticTask & | | ) |
|
|
delete |
◆ StaticTask() [3/3]
◆ create()
| bool esphome::StaticTask::create |
( |
TaskFunction_t | fn, |
|
|
const char * | name, |
|
|
uint32_t | stack_size, |
|
|
void * | param, |
|
|
UBaseType_t | priority, |
|
|
bool | use_psram, |
|
|
BaseType_t | core_id = tskNO_AFFINITY ) |
Allocate the TCB (always internal RAM) and the stack, then create the task.
- Parameters
-
| fn | Task function |
| name | Task name (for debug) |
| stack_size | Stack size in bytes (StackType_t is a byte on ESP-IDF) |
| param | Parameter passed to task function |
| priority | FreeRTOS task priority |
| use_psram | If true, allocate stack in PSRAM; otherwise internal RAM |
| core_id | CPU core, or tskNO_AFFINITY to leave scheduling unrestricted |
- Returns
- true on success; false if either allocation fails or the task cannot be created
Definition at line 9 of file static_task.cpp.
◆ deallocate()
| bool esphome::StaticTask::deallocate |
( |
| ) |
|
Delete the task (if created) and free the TCB and stack buffer.
- Returns
- true if the buffers were freed; false if the task is still running on another core, in which case the caller should try again later.
Definition at line 71 of file static_task.cpp.
◆ destroy()
| bool esphome::StaticTask::destroy |
( |
| ) |
|
Delete the task, keeping the TCB and stack buffer allocated for reuse by a subsequent create() call.
The task must have finished its work and parked itself, either suspended or blocked indefinitely: it is suspended here so that it cannot be scheduled again, and it is given no chance to clean up.
- Returns
- true if the task was deleted; false if it is still running on another core, in which case the caller should try again later.
Definition at line 50 of file static_task.cpp.
◆ get_handle()
| TaskHandle_t esphome::StaticTask::get_handle |
( |
| ) |
const |
|
inline |
◆ is_created()
| bool esphome::StaticTask::is_created |
( |
| ) |
const |
|
inline |
Check if the task has been created and not yet destroyed.
Definition at line 28 of file static_task.h.
◆ operator=() [1/2]
◆ operator=() [2/2]
◆ handle_
| TaskHandle_t esphome::StaticTask::handle_ {nullptr} |
|
protected |
◆ stack_buffer_
| RAMUniquePtr<StackType_t[]> esphome::StaticTask::stack_buffer_ |
|
protected |
◆ stack_size_
| uint32_t esphome::StaticTask::stack_size_ {0} |
|
protected |
◆ tcb_
◆ use_psram_
| bool esphome::StaticTask::use_psram_ {false} |
|
protected |
The documentation for this class was generated from the following files: