Template Function exathread::yieldFor

Function Documentation

template<typename Rep, typename Period>
details::YieldOp exathread::yieldFor(const std::chrono::duration<Rep, Period> &duration)

Suspend execution of your task and allow other tasks to run for a certain period of time.

Note

As the use of this function makes your function a coroutine, it must explicitly return either a VoidTask or ValueTask and use co_return to be valid

Parameters:

duration – The amount of time to yield for. It is not guaranteed that execution will resume exactly at the specified time amount

Returns:

An awaitable object; you must use co_await on this result to yield correctly