yield


Defer computation of the current function by passing control back to the event loop. This defers the execution of the function without blocking the event loop. User are able to specifiy a delay to the yield or specify a thread to return into.


Example
async_function<>
your_class::delay() noexcept
{
    /* wait 10 seconds then resume in thread 2. */
    co_await yield(
        order::now() + order::seconds(10),
        thread_t{2}
        );
}

Classes that inherit from engine_enabled can forgo the engine* paremeter.


inline auto zab::yield(engine *_engine) noexcept

Yields execution of the current coroutine.

@co_return void Will be resumed by the engine in the current thread.

Parameters

_engine[in] The engine to yield into.

inline auto zab::yield(engine *_engine, thread_t _thread) noexcept

Yields execution of the current coroutine.

@co_return void Will be resumed by the engine in _thread.

Parameters
  • _engine[in] The engine to yield into.

  • _thread[in] The thread to resume in.

inline auto zab::yield(engine *_engine, order_t _order, thread_t _thread) noexcept

Yields execution of the current coroutine.

@co_return void Will be resumed by the engine in _thread after _order nanoseconds have passed.

Parameters
  • _engine[in] The engine to yield into.

  • _order[in] The orderring to apply to the event loop.

  • _thread[in] The thread to resume in.