|
ESPHome 2026.10.2
|
Helper for FreeRTOS static task management. More...
#include <static_task.h>
Public Member Functions | |
| StaticTask ()=default | |
| StaticTask (const StaticTask &)=delete | |
| StaticTask & | operator= (const StaticTask &)=delete |
| StaticTask (StaticTask &&)=delete | |
| StaticTask & | operator= (StaticTask &&)=delete |
| bool | is_created () const |
| Check if the task has been created and not yet destroyed. | |
| TaskHandle_t | get_handle () const |
| Get the FreeRTOS task handle. | |
| bool | create (TaskFunction_t fn, const char *name, uint32_t stack_size, void *param, UBaseType_t priority, bool use_psram) |
| Allocate the TCB (always internal RAM) and the stack, then create the task. | |
| bool | destroy () |
| Delete the task, keeping the TCB and stack buffer allocated for reuse by a subsequent create() call. | |
| bool | deallocate () |
| Delete the task (if created) and free the TCB and stack buffer. | |
Protected Attributes | |
| TaskHandle_t | handle_ {nullptr} |
| RAMUniquePtr< StaticTask_t > | tcb_ |
| RAMUniquePtr< StackType_t[]> | stack_buffer_ |
| uint32_t | stack_size_ {0} |
| bool | use_psram_ {false} |
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.
|
default |
|
delete |
|
delete |
| bool esphome::StaticTask::create | ( | TaskFunction_t | fn, |
| const char * | name, | ||
| uint32_t | stack_size, | ||
| void * | param, | ||
| UBaseType_t | priority, | ||
| bool | use_psram ) |
Allocate the TCB (always internal RAM) and the stack, then create the task.
| 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 |
Definition at line 9 of file static_task.cpp.
| bool esphome::StaticTask::deallocate | ( | ) |
Delete the task (if created) and free the TCB and stack buffer.
Definition at line 71 of file static_task.cpp.
| 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.
Definition at line 50 of file static_task.cpp.
|
inline |
Get the FreeRTOS task handle.
Definition at line 31 of file static_task.h.
|
inline |
Check if the task has been created and not yet destroyed.
Definition at line 28 of file static_task.h.
|
delete |
|
delete |
|
protected |
Definition at line 57 of file static_task.h.
|
protected |
Definition at line 59 of file static_task.h.
|
protected |
Definition at line 60 of file static_task.h.
|
protected |
Definition at line 58 of file static_task.h.
|
protected |
Definition at line 61 of file static_task.h.