Thread-safe notification with a single asynchronous listener. More...
#include <notifier.hpp>
Public Member Functions | |
| TNotifier (TPollerBase &poller) | |
| Creates a notifier bound to the listener's event-loop poller. | |
| TNotifier (const TNotifier &)=delete | |
| TNotifier & | operator= (const TNotifier &)=delete |
| void | Notify () |
| Signals the listener from any thread. | |
| TFuture< void > | Wait () |
| Asynchronously waits for and consumes a notification. | |
Thread-safe notification with a single asynchronous listener.
Producers call Notify() from any thread after publishing work. Calls coalesce until Wait() consumes the signal; a notification means "check for work", not one work item. Wait() re-arms the notifier before returning to the listener.
| void NNet::TNotifier::Notify | ( | ) |
Signals the listener from any thread.
Only the first call writes to the wakeup descriptor until the listener consumes the signal. A notification sent before Wait() is retained.
| TFuture< void > NNet::TNotifier::Wait | ( | ) |
Asynchronously waits for and consumes a notification.
Call on the poller thread, with at most one outstanding wait. The caller must check all available work after waking because notifications coalesce. Destroying an unfinished future cancels its wait on the poller thread.
| std::logic_error | if another wait is already outstanding. |