pub struct ThreadSender<T> { /* private fields */ }Expand description
A thread-safe channel sender for intra-process communication.
This is the sending half of a ThreadChannel. It can be cloned to create
multiple producers that send to the same channel.
Implementations§
Source§impl<T> ThreadSender<T>
impl<T> ThreadSender<T>
Sourcepub fn send(&self, msg: T) -> Result<()>
pub fn send(&self, msg: T) -> Result<()>
Send a message through the channel.
This method blocks if the channel is bounded and full.
§Errors
Returns IpcError::Closed if the channel has been shutdown or all receivers have been dropped.
Sourcepub fn try_send(&self, msg: T) -> Result<()>
pub fn try_send(&self, msg: T) -> Result<()>
Try to send a message without blocking.
§Errors
IpcError::Closedif the channel has been shutdown or all receivers have been dropped.IpcError::WouldBlockif the channel is full (bounded channels only).
Sourcepub fn send_timeout(&self, msg: T, timeout: Duration) -> Result<()>
pub fn send_timeout(&self, msg: T, timeout: Duration) -> Result<()>
Send a message with a timeout.
§Errors
IpcError::Closedif the channel has been shutdown or all receivers have been dropped.IpcError::Timeoutif the timeout expires before the message can be sent.
Sourcepub fn is_full(&self) -> bool
pub fn is_full(&self) -> bool
Check if the channel is full (always false for unbounded channels).
Sourcepub fn capacity(&self) -> Option<usize>
pub fn capacity(&self) -> Option<usize>
Get the capacity of the channel (None for unbounded channels).
Sourcepub fn is_shutdown(&self) -> bool
pub fn is_shutdown(&self) -> bool
Check if the channel has been shutdown.
Trait Implementations§
Source§impl<T> Clone for ThreadSender<T>
impl<T> Clone for ThreadSender<T>
Source§impl<T: Debug> Debug for ThreadSender<T>
impl<T: Debug> Debug for ThreadSender<T>
Source§impl<T> GracefulChannel for ThreadSender<T>
impl<T> GracefulChannel for ThreadSender<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 ThreadSender<T>
impl<T> RefUnwindSafe for ThreadSender<T>
impl<T> Send for ThreadSender<T>where
T: Send,
impl<T> Sync for ThreadSender<T>where
T: Send,
impl<T> Unpin for ThreadSender<T>
impl<T> UnwindSafe for ThreadSender<T>
Blanket Implementations§
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
🔬This is a nightly-only experimental API. (
clone_to_uninit)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.