pub struct EventBroadcasters { /* private fields */ }Expand description
Manage a collection of event channel senders for broadcasting agent events to multiple subscribers.
Stores Vec<mpsc::Sender<AgentEvent>> protected by a parking_lot::Mutex.
broadcast() sends an event to all active subscribers and removes closed
channels. subscribe() creates a new (EventSubscriber, CancelGuard) pair.
Implementations§
Source§impl EventBroadcasters
impl EventBroadcasters
pub fn new() -> Self
Sourcepub fn broadcast(&self, event: &AgentEvent)
pub fn broadcast(&self, event: &AgentEvent)
Send an event to all active subscribers.
Iterates all channel senders, attempting to send the event to each. Removes (and drops) senders whose receiver has been disconnected, keeping the list lean.
Sourcepub fn subscribe(&self) -> (EventSubscriber, CancelGuard)
pub fn subscribe(&self) -> (EventSubscriber, CancelGuard)
Subscribe to events.
Creates a new channel and registers the sender. Returns an
EventSubscriber (the receiver) and a CancelGuard that will
automatically remove the sender when dropped.
Trait Implementations§
Source§impl Clone for EventBroadcasters
impl Clone for EventBroadcasters
Source§fn clone(&self) -> EventBroadcasters
fn clone(&self) -> EventBroadcasters
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for EventBroadcasters
impl !RefUnwindSafe for EventBroadcasters
impl Send for EventBroadcasters
impl Sync for EventBroadcasters
impl Unpin for EventBroadcasters
impl UnsafeUnpin for EventBroadcasters
impl !UnwindSafe for EventBroadcasters
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more