Skip to main content

SubscribeTicker

Struct SubscribeTicker 

Source
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>
where T: Clone + Send + Sync + 'static,

Source

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:

  1. Receives an event from any of the registered receivers
  2. Emits the event to all registered subscribers
  3. 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.

Source

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:

  1. Attempts to receive an event from the receiver without blocking
  2. If an event is received, spawns a task to process it asynchronously
  3. 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§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V