pub struct ChannelDispatcher<T> { /* private fields */ }
Expand description
A unified thread-safe interface for dispatching subscriptions.
§Type Parameters
T
- The type of subscriptions being dispatched. Must implementSend + 'static
.
Implementations§
Source§impl<T: Send + 'static> ChannelDispatcher<T>
impl<T: Send + 'static> ChannelDispatcher<T>
Sourcepub fn new(mode: ChannelMode, channel_size: usize, name: String) -> Self
pub fn new(mode: ChannelMode, channel_size: usize, name: String) -> Self
Creates a new channel dispatcher with the specified mode and channel capacity.
Sourcepub fn dispatch(
&self,
data: T,
core_id: Option<&CoreId>,
) -> Result<(), DispatchError<T>>
pub fn dispatch( &self, data: T, core_id: Option<&CoreId>, ) -> Result<(), DispatchError<T>>
Dispatches data to appropriate channel based on the dispatcher’s mode.
In either case, the subscription passing is non-blocking through crossbeam’s try_send operation and doesn’t rely on mutexes internally (relies on lower-level atomic operations).
Sourcepub fn receivers(&self) -> Vec<Arc<Receiver<T>>>
pub fn receivers(&self) -> Vec<Arc<Receiver<T>>>
Returns a vector of all receivers for subscription consumption.
Sourcepub fn close_channels(&self)
pub fn close_channels(&self)
Manually closes all channels.
Sourcepub fn stats(&self) -> &SubscriptionStats
pub fn stats(&self) -> &SubscriptionStats
Returns a reference to the dispatch statistics.
Auto Trait Implementations§
impl<T> !Freeze for ChannelDispatcher<T>
impl<T> RefUnwindSafe for ChannelDispatcher<T>
impl<T> Send for ChannelDispatcher<T>where
T: Send,
impl<T> Sync for ChannelDispatcher<T>where
T: Send,
impl<T> Unpin for ChannelDispatcher<T>
impl<T> UnwindSafe for ChannelDispatcher<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
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more