Yielding or Rescheduling#
Yielding to Higher Priority Tasks#
-
constexpr aw_yield tmc::yield()#
Returns an awaitable that suspends this task and resubmits it back to its current executor, so that a higher priority task can run. Note that this can only be used to yield to a higher priority task; it cannot be used to enforce fair scheduling among tasks of the same priority level. If you need to do that, use
tmc::reschedule()instead.
-
inline bool tmc::yield_requested()#
Returns true if a higher priority task is requesting to run on this thread.
-
constexpr aw_yield_if_requested tmc::yield_if_requested()#
Returns an awaitable that suspends this task only if a higher priority task is requesting to run on this thread.
co_await yield_if_requested();is equivalent to
if (yield_requested()) { co_await yield();}
-
template<ptrdiff_t N>
inline aw_yield_counter<N> tmc::check_yield_counter()# Returns an awaitable that, every
Ncalls toco_await, checksyield_requested()and yields if that returns true. The counterpart functioncheck_yield_counter_dynamic()allows passingNas a runtime parameter.
-
inline aw_yield_counter_dynamic tmc::check_yield_counter_dynamic(size_t N)#
Returns an awaitable that, every
Ncalls toco_await, checksyield_requested()and yields if that returns true. The counterpart functioncheck_yield_counter()allows settingNas a template parameter.
Rescheduling Tasks for Fairness#
-
constexpr aw_reschedule tmc::reschedule()#
Returns an awaitable that suspends this task and resubmits it back to its current executor using the FIFO inbox. This can be used to enforce fair scheduling among tasks of the same priority level.