pub struct ThreadChannel<T> { /* private fields */ }Expand description
A bidirectional thread channel that combines both sender and receiver.
This is useful when you need both send and receive capabilities in one place.
Implementations§
Source§impl<T> ThreadChannel<T>
impl<T> ThreadChannel<T>
Sourcepub fn unbounded() -> (ThreadSender<T>, ThreadReceiver<T>)
pub fn unbounded() -> (ThreadSender<T>, ThreadReceiver<T>)
Create a new unbounded thread channel.
An unbounded channel has no capacity limit and will never block on send.
§Returns
A tuple of (sender, receiver) for the channel.
Sourcepub fn bounded(capacity: usize) -> (ThreadSender<T>, ThreadReceiver<T>)
pub fn bounded(capacity: usize) -> (ThreadSender<T>, ThreadReceiver<T>)
Sourcepub fn new_unbounded() -> Self
pub fn new_unbounded() -> Self
Create a new bidirectional thread channel (unbounded).
Sourcepub fn new_bounded(capacity: usize) -> Self
pub fn new_bounded(capacity: usize) -> Self
Create a new bidirectional thread channel (bounded).
Sourcepub fn sender(&self) -> &ThreadSender<T>
pub fn sender(&self) -> &ThreadSender<T>
Get a reference to the sender.
Sourcepub fn receiver(&self) -> &ThreadReceiver<T>
pub fn receiver(&self) -> &ThreadReceiver<T>
Get a reference to the receiver.
Sourcepub fn clone_sender(&self) -> ThreadSender<T>
pub fn clone_sender(&self) -> ThreadSender<T>
Clone the sender.
Sourcepub fn clone_receiver(&self) -> ThreadReceiver<T>
pub fn clone_receiver(&self) -> ThreadReceiver<T>
Clone the receiver.
Sourcepub fn split(self) -> (ThreadSender<T>, ThreadReceiver<T>)
pub fn split(self) -> (ThreadSender<T>, ThreadReceiver<T>)
Split the channel into sender and receiver.
Trait Implementations§
Source§impl<T: Debug> Debug for ThreadChannel<T>
impl<T: Debug> Debug for ThreadChannel<T>
Source§impl<T> GracefulChannel for ThreadChannel<T>
impl<T> GracefulChannel for ThreadChannel<T>
Source§fn is_shutdown(&self) -> bool
fn is_shutdown(&self) -> bool
Check if the channel has been signaled to shutdown
Auto Trait Implementations§
impl<T> Freeze for ThreadChannel<T>
impl<T> RefUnwindSafe for ThreadChannel<T>
impl<T> Send for ThreadChannel<T>where
T: Send,
impl<T> Sync for ThreadChannel<T>where
T: Send,
impl<T> Unpin for ThreadChannel<T>where
T: Unpin,
impl<T> UnsafeUnpin for ThreadChannel<T>
impl<T> UnwindSafe for ThreadChannel<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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoMetered for T
impl<T> IntoMetered for T
Source§fn metered(self, metrics: Arc<ChannelMetrics>) -> MeteredSender<Self>
fn metered(self, metrics: Arc<ChannelMetrics>) -> MeteredSender<Self>
Wrap this sender with metrics tracking.
Source§impl<T> WithMetrics for T
impl<T> WithMetrics for T
Source§fn with_metrics(self) -> MeteredWrapper<Self>
fn with_metrics(self) -> MeteredWrapper<Self>
Wrap this channel with metrics tracking.