pub struct EventListener { /* private fields */ }Expand description
A listener to an Event. It completes when a notification reaches it.
Event::listen creates one and puts it at the back of the event’s queue. Every notification
sent from then on can reach it, even if it has not been polled yet.
A notification that reaches the listener wakes the task that polled it last, and the listener
completes on its next poll. Polling it again after it completed returns Ready at once.
§Dropping a listener
Dropping a listener removes it from the queue. If the listener was notified but had not completed, it passes its notification on to the next listener:
- If
Event::notifysent the notification, the next listener gets it only if no other listener is notified at that point. - If
Event::notify_additionalsent it, the next listener always gets it.
Passing a notification on wakes the next listener’s task, so a waker that panics can make the drop panic.
§Outliving the event
A listener can outlive its Event. Dropping the event notifies nobody. A listener that was
notified before that still completes. One that was not stays pending, unless a notified listener
passes its notification on to it when dropped.