...

/

Awaitables and Awaiters

Awaitables and Awaiters

Get a detailed understanding of crucial abstraction in the coroutine framework known as 'awaitables' and 'awaiters'.

The three functions of a promise object: yield_value, initial_suspend, and final_suspend return awaitables.

Awaitables

An Awaitable is something you can await on. The awaitable determines if the coroutine pauses or not.

Essentially, the compiler generates the three functions calls using the promise prom and the co_await operator.

Call Compiler generated call
yield value co_await prom.yield_value(value)
prom.initial_suspend() co_await prom.initial_suspend()
prom.final_suspend() co_await prom.final_suspend()

The co_await operator needs an awaitable as argument. ...