pub struct SubscribeTicker<T: 'static> {
pub subs: Subscribers<T>,
pub rx: UnboundedReceiver<EventData>,
pub err_queue: Arc<SegQueue<CallSubscribeError>>,
}Expand description
A ticker that manages event distribution to subscribers.
This component is responsible for:
- Receiving events from registered channels
- Distributing events to matching subscribers
- Managing subscriber lifecycle and error handling
§Examples
use ioevent::prelude::*;
let mut subscribe_ticker = SubscribeTicker {
subs: subscribers,
rx: receiver,
};
subscribe_ticker.tick(&state).await;Fields§
§subs: Subscribers<T>Collection of subscribers that receive events
rx: UnboundedReceiver<EventData>Collection of event receivers
err_queue: Arc<SegQueue<CallSubscribeError>>Queue of errors that occurred during event distribution
Implementations§
Source§impl<T> SubscribeTicker<T>
impl<T> SubscribeTicker<T>
Sourcepub async fn tick(
&mut self,
state: &State<T>,
) -> impl Iterator<Item = CallSubscribeError> + Send + 'static
pub async fn tick( &mut self, state: &State<T>, ) -> impl Iterator<Item = CallSubscribeError> + Send + 'static
Receives and distributes events to subscribers.
This method performs the following operations:
- Receives an event from any of the registered receivers
- Emits the event to all registered subscribers
- Processes any event shooters that may be waiting for this event
§Returns
Ok(Iterator<Item = CallSubscribeError>): An iterator over any errors that occurred while emitting events to subscribers. Empty if all emissions were successful.Err(BusRecvError<R::Error>): If all receivers failed to receive an event.
§Cancel Safety
This method is NOT! cancel-safe.
Sourcepub async fn try_tick(
&mut self,
state: &State<T>,
) -> impl Iterator<Item = CallSubscribeError> + Send + 'static
pub async fn try_tick( &mut self, state: &State<T>, ) -> impl Iterator<Item = CallSubscribeError> + Send + 'static
Attempts to process events without blocking.
This method performs the following operations:
- Attempts to receive an event from the receiver without blocking
- If an event is received, spawns a task to process it asynchronously
- Collects any errors that occurred during processing
§Arguments
state- The current state
§Returns
An iterator over any errors that occurred during event processing. The iterator will be empty if no event was received or if all processing was successful.
§Cancel Safety
This method is cancel-safe, meaning it can be safely cancelled at any point without leaving the system in an inconsistent state.
Auto Trait Implementations§
impl<T> Freeze for SubscribeTicker<T>
impl<T> RefUnwindSafe for SubscribeTicker<T>
impl<T> Send for SubscribeTicker<T>
impl<T> Sync for SubscribeTicker<T>
impl<T> Unpin for SubscribeTicker<T>
impl<T> UnsafeUnpin for SubscribeTicker<T>
impl<T> UnwindSafe for SubscribeTicker<T>
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