|
idfxx 1.0.0
Modern C++23 components for ESP-IDF
|
Delay and yield functions for task scheduling. More...
Namespaces | |
| namespace | idfxx |
Functions | |
| template<typename Rep , typename Period > | |
| void | idfxx::delay (const std::chrono::duration< Rep, Period > &duration) |
| Delay for the specified duration. | |
| template<typename Clock , typename Duration > | |
| void | idfxx::delay_until (const std::chrono::time_point< Clock, Duration > &target) |
| Delays until the specified time point. | |
| void | idfxx::yield () noexcept |
| Yields execution to other ready tasks of equal priority. | |
| void | idfxx::yield_from_isr (bool higher_priority_task_woken=true) noexcept |
| Requests a context switch from ISR context. | |
Delay and yield functions for task scheduling.
Provides scheduling primitives for the current task context:
| void idfxx::delay | ( | const std::chrono::duration< Rep, Period > & | duration | ) |
Delay for the specified duration.
Automatically selects the appropriate delay method:
ets_delay_us (busy-wait, microsecond precision)vTaskDelay (yields to scheduler, tick-based)| Rep | The representation type of the duration. |
| Period | The period type of the duration. |
| duration | The duration to delay for. |
Definition at line 43 of file sched.hpp.
References idfxx::delay().
Referenced by idfxx::delay(), and idfxx::delay_until().
| void idfxx::delay_until | ( | const std::chrono::time_point< Clock, Duration > & | target | ) |
Delays until the specified time point.
Computes the remaining time from Clock::now() to the target time point and delays for that duration. If the target time has already passed, returns immediately without delaying.
This is useful for periodic timing loops where execution time between iterations should not cause drift:
| Clock | The clock type (must provide Clock::now()). |
| Duration | The duration type of the time point. |
| target | The time point to delay until. |
Definition at line 77 of file sched.hpp.
References idfxx::delay().
|
inlinenoexcept |
|
noexcept |
Requests a context switch from ISR context.
Call this at the end of an ISR when a FreeRTOS API has indicated that a higher priority task was woken. This ensures the scheduler switches to the higher priority task immediately upon ISR completion rather than waiting for the next tick.
| higher_priority_task_woken | true if a higher priority task was woken by a FreeRTOS call during the ISR, false otherwise. When false, no context switch is requested. Defaults to true for unconditional context switch. |