feat(tokio-util): EventListeners with Listener Management (#5136)

Co-authored-by: Matthias Seitz <matthias.seitz@outlook.de>
This commit is contained in:
DoTheBestToGetTheBest
2023-10-23 10:02:39 -07:00
committed by GitHub
parent fbf12de4e4
commit 36dde36479

View File

@ -33,4 +33,14 @@ impl<T: Clone> EventListeners<T> {
pub fn push_listener(&mut self, listener: mpsc::UnboundedSender<T>) {
self.listeners.push(listener);
}
/// Returns the number of registered listeners.
pub fn len(&self) -> usize {
self.listeners.len()
}
/// Returns true if there are no registered listeners.
pub fn is_empty(&self) -> bool {
self.listeners.is_empty()
}
}