Ownership-based wrapper for a task/thread execution object.
More...
#include <freertos_task.hpp>
|
| using | TaskFunction = std::function< void(void *)> |
| | Task callable signature.
|
| |
|
| static void | Delay (std::uint32_t ticks) |
| | Delay current task for a number of ticks.
|
| |
| static void | Yield () |
| | Yield current task.
|
| |
| static std::uint32_t | GetTickCount () |
| |
| static void | StartScheduler () |
| | Start the scheduler.
|
| |
| static std::uint32_t | MsToTicks (std::uint32_t milliseconds) |
| | Convert milliseconds to scheduler ticks.
|
| |
| static std::uint32_t | IdlePriority () |
| |
|
| static constexpr std::uint32_t | kInfinite = std::numeric_limits<std::uint32_t>::max() |
| | Sentinel tick value representing an infinite wait.
|
| |
Ownership-based wrapper for a task/thread execution object.
The wrapper owns a task handle and stores a C++ callable task body. Platform implementations bridge the native task entry point to RunTaskBody(). RAII here refers to task-handle cleanup on destruction.
Typical usage:
void Worker(void* arg) {
(void)arg;
for(;;) {
}
}
Ownership-based wrapper for a task/thread execution object.
Definition freertos_task.hpp:36
static void Delay(std::uint32_t ticks)
Delay current task for a number of ticks.
static std::uint32_t MsToTicks(std::uint32_t milliseconds)
Convert milliseconds to scheduler ticks.
static std::uint32_t IdlePriority()
◆ TaskFunction
◆ FreeRtosTask() [1/2]
| c7222::FreeRtosTask::FreeRtosTask |
( |
| ) |
|
|
default |
Construct an uninitialized task wrapper.
◆ FreeRtosTask() [2/2]
| c7222::FreeRtosTask::FreeRtosTask |
( |
const char * |
name, |
|
|
std::uint32_t |
stack_depth_words, |
|
|
std::uint32_t |
priority, |
|
|
TaskFunction |
task_function, |
|
|
void * |
task_arg = nullptr |
|
) |
| |
Construct and initialize a task.
- Parameters
-
| name | Task name. |
| stack_depth_words | Stack depth in words. |
| priority | Initial task priority. |
| task_function | Callable run as the task body. |
| task_arg | Argument passed to task_function. |
◆ ~FreeRtosTask()
| c7222::FreeRtosTask::~FreeRtosTask |
( |
| ) |
|
Delete owned task resource if initialized.
◆ Delay()
| static void c7222::FreeRtosTask::Delay |
( |
std::uint32_t |
ticks | ) |
|
|
static |
Delay current task for a number of ticks.
◆ Delete()
| bool c7222::FreeRtosTask::Delete |
( |
std::uint32_t |
ticks_to_wait = 0 | ) |
|
Delete the task.
- Parameters
-
| ticks_to_wait | Optional platform-specific wait. |
- Returns
- true if a task was deleted.
◆ GetHandle()
| void * c7222::FreeRtosTask::GetHandle |
( |
| ) |
const |
- Returns
- Opaque platform task handle.
◆ GetPriority()
| std::uint32_t c7222::FreeRtosTask::GetPriority |
( |
| ) |
const |
Get current task priority.
◆ GetTickCount()
| static std::uint32_t c7222::FreeRtosTask::GetTickCount |
( |
| ) |
|
|
static |
- Returns
- Current scheduler tick count.
◆ IdlePriority()
| static std::uint32_t c7222::FreeRtosTask::IdlePriority |
( |
| ) |
|
|
static |
- Returns
- Idle task priority.
◆ Initialize()
| bool c7222::FreeRtosTask::Initialize |
( |
const char * |
name, |
|
|
std::uint32_t |
stack_depth_words, |
|
|
std::uint32_t |
priority, |
|
|
TaskFunction |
task_function, |
|
|
void * |
task_arg = nullptr |
|
) |
| |
Initialize (or re-initialize) a task.
- Returns
- true on successful creation/start.
◆ IsRunning()
| bool c7222::FreeRtosTask::IsRunning |
( |
| ) |
const |
- Returns
- true if the task is currently considered running/alive.
◆ IsValid()
| bool c7222::FreeRtosTask::IsValid |
( |
| ) |
const |
- Returns
- true if wrapper owns a valid task handle.
◆ MsToTicks()
| static std::uint32_t c7222::FreeRtosTask::MsToTicks |
( |
std::uint32_t |
milliseconds | ) |
|
|
static |
Convert milliseconds to scheduler ticks.
◆ Resume()
| bool c7222::FreeRtosTask::Resume |
( |
| ) |
|
Resume the task from task context.
◆ ResumeFromISR()
| bool c7222::FreeRtosTask::ResumeFromISR |
( |
| ) |
|
Resume the task from ISR context.
◆ RunTaskBody()
| void c7222::FreeRtosTask::RunTaskBody |
( |
| ) |
|
Internal bridge used by platform task-entry trampolines.
Public by design to avoid friend declarations for C-linkage bridge code.
◆ SetPriority()
| bool c7222::FreeRtosTask::SetPriority |
( |
std::uint32_t |
priority | ) |
|
◆ StartScheduler()
| static void c7222::FreeRtosTask::StartScheduler |
( |
| ) |
|
|
static |
◆ Suspend()
| bool c7222::FreeRtosTask::Suspend |
( |
| ) |
|
◆ Yield()
| static void c7222::FreeRtosTask::Yield |
( |
| ) |
|
|
static |
◆ kInfinite
| constexpr std::uint32_t c7222::FreeRtosTask::kInfinite = std::numeric_limits<std::uint32_t>::max() |
|
staticconstexpr |
Sentinel tick value representing an infinite wait.
The documentation for this class was generated from the following file: