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 does `co_await` actually return? [closed]
Closed 18 mins ago.
Coroutine return_void; difference between co_return; and falling off the end
On cppreference I read the following (emphasis mine):
How would std::optional need to be modified in order to make it a monad via coroutines?
There’s not really much when searching for c++coroutine “optional”, but from the final part of this answer I’d deduce that std::optional
can’t be made a coroutine non-intrusively. However, I want to understand the details of this fact.
What happens when a coroutine returns to a suspended coroutine?
Suppose I have two coroutines, coroutine_a
and coroutine_b
. In coroutine_a
it calls:
What is the standard behavior for await_suspend that returns a handle
Let an Awaiter return a handle, H, in its await_suspend.
What is the best way to make a coroutin an awaitable type?
Let task foo()
be a coroutine. I want to support:
std::jthread destructor not blocking if destroyed on coroutine activation frame?
I was playing with cpprefernce’s code pulling the out_thread into resuming_on_new_thread coroutine:
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.