pub struct SubscriberSet { /* private fields */ }Expand description
Fan-out coordinator for multiple event subscribers.
Manages per-subscriber queues and worker tasks, providing:
- Concurrent delivery: events are sent to all subscribers simultaneously
- Isolation: each subscriber has a dedicated queue and worker
- Panic safety: panics are caught and reported, do not crash the runtime
- Overflow handling: dropped events are reported via
SubscriberOverflow
Implementations§
Source§impl SubscriberSet
impl SubscriberSet
Sourcepub fn new(subs: Vec<Arc<dyn Subscribe>>, bus: Bus) -> Self
pub fn new(subs: Vec<Arc<dyn Subscribe>>, bus: Bus) -> Self
Creates a new set and spawns one worker task per subscriber.
§Per-subscriber setup
- Bounded
mpscqueue (capacity fromSubscribe::queue_capacity, clamped to >= 1) - Dedicated worker task (runs until the queue is closed)
- Panic isolation via
catch_unwind
§Notes
- Workers start immediately and process events until shutdown
Sourcepub fn emit_arc(&self, event: Arc<Event>)
pub fn emit_arc(&self, event: Arc<Event>)
Emits a pre-allocated Arc<Event> to all subscribers.
- Uses
try_send(non-blocking) - On queue full: drops the event, publishes
SubscriberOverflow - On queue closed: publishes
SubscriberOverflowwith reason “closed”
§Overflow prevention
Prevents infinite loops and event storms: if the incoming event is
SubscriberOverflow or SubscriberPanicked, we do not publish further
overflow diagnostics for it.
Auto Trait Implementations§
impl Freeze for SubscriberSet
impl RefUnwindSafe for SubscriberSet
impl Send for SubscriberSet
impl Sync for SubscriberSet
impl Unpin for SubscriberSet
impl UnwindSafe for SubscriberSet
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