Relative Content

Tag Archive for c++c++20c++-coroutine

C++ Coroutines promise type

I’ve recently learnt about coroutines, and got excited as I maintain several async libraries, for which to support coroutines for at least the base library -the task scheduler-.

C++ Coroutines promise type

I’ve recently learnt about coroutines, and got excited as I maintain several async libraries, for which to support coroutines for at least the base library -the task scheduler-.

What are the actual rules for final_suspend’s awaiter in C++ coroutines?

In C++ coroutines, the promise type’s final_suspend member function can return any arbitrary awaitable type, though commonly it’s std::suspend_always which leaves the responsibility to someone else to destroy the coroutine, or std::suspend_never which automatically destroys the coroutine. The latter seems to be a special case, since normally it is not allowed to resume a coroutine that is at its final suspend point. In my testing though, it seems like this special behavior is not uniformly applied.