idfxx 1.0.0
Modern C++23 components for ESP-IDF
Loading...
Searching...
No Matches
sched.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: Apache-2.0
2// Copyright 2026 Chris Leishman
3
4#pragma once
5
22#include <chrono>
23#include <freertos/FreeRTOS.h>
24#include <freertos/task.h>
25
26namespace idfxx {
27
42template<typename Rep, typename Period>
43void delay(const std::chrono::duration<Rep, Period>& duration) {
44 delay(std::chrono::ceil<std::chrono::microseconds>(duration));
45}
46
48template<>
49void delay(const std::chrono::microseconds& duration);
51
76template<typename Clock, typename Duration>
77void delay_until(const std::chrono::time_point<Clock, Duration>& target) {
78 auto remaining = target - Clock::now();
79 if (remaining > decltype(remaining)::zero()) {
80 delay(remaining);
81 }
82}
83
87inline void yield() noexcept {
88 taskYIELD();
89}
90
111void yield_from_isr(bool higher_priority_task_woken = true) noexcept;
112
// end of idfxx_core_sched // end of idfxx_core
115
116} // namespace idfxx
void yield_from_isr(bool higher_priority_task_woken=true) noexcept
Requests a context switch from ISR context.
void delay_until(const std::chrono::time_point< Clock, Duration > &target)
Delays until the specified time point.
Definition sched.hpp:77
void yield() noexcept
Yields execution to other ready tasks of equal priority.
Definition sched.hpp:87
void delay(const std::chrono::duration< Rep, Period > &duration)
Delay for the specified duration.
Definition sched.hpp:43