Async++ unknown
Async (co_await/co_return) code for C++
|
Simple auto reset event supporting multiple consumers. More...
#include <asyncpp/event.h>
Simple auto reset event supporting multiple consumers.
This is similar in concept to a std::condition_variable and allows synchronization between coroutines, as well as normal code and coroutines. If the current coroutine co_await's the event it is suspended until some other coroutine or thread calls set(). If the event is already set when calling co_await the coroutine will directly continue execution in the current thread. If the event is not set, the coroutine gets resumed on the dispatcher that's passed into wait() or inside the call to set() if no dispatcher was provided. The operator co_await will behave as if wait() was called with the result of dispatcher::current(), meaning the coroutine is resumed on the same dispatcher it suspended (not necessarily the same thread, e.g. on a thread pool). If no dispatcher is associated with the current thread it is resumed inside set(). Unlike multi_consumer_event
this does not need to get reset manually, it is automatically reset once a suspended coroutine is resumed.