Thread-safe notification with a single asynchronous listener. More...
#include <notifier.hpp>
Public Member Functions | |
| TNotifier (TPoller &poller) | |
| Creates a notifier bound to the listener's event-loop poller. | |
| TNotifier (const TNotifier &)=delete | |
| TNotifier & | operator= (const TNotifier &)=delete |
| void | Notify () override |
| Signals the listener from any thread. | |
| TFuture< void > | Wait () override |
| 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.
Code that must not depend on the poller type holds an INotifier&.
| TPoller | The poller type of the listener's event loop; deduced from the constructor argument. |
|
inlineoverridevirtual |
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.
Implements NNet::INotifier.
|
inlineoverridevirtual |
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. |
Implements NNet::INotifier.