Async++ unknown
Async (co_await/co_return) code for C++
Loading...
Searching...
No Matches
asyncpp::multi_consumer_auto_reset_event Class Reference

Simple auto reset event supporting multiple consumers. More...

#include <asyncpp/event.h>

Detailed Description

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.

Note
multi_consumer_auto_reset_event is threadsafe and multiple consumers can await it. Calling set() or is_set() from different threads at arbitrary times is safe, though it might be hard to predict the results.
Destroying a event thats currently being awaited can cause resource leaks as the waiting coroutine can never resume. (This asserts in debug mode)

The documentation for this class was generated from the following file: