Struct two_lock_queue::Sender
[−]
[src]
pub struct Sender<T> { /* fields omitted */ }
The sending-half of the channel.
Each instance of Sender
can only be used in a single thread, but it can be
cloned to create new Sender
instances for the same underlying channel and
these new instances can be sent to other threads.
Methods
impl<T> Sender<T>
[src]
fn send(&self, t: T) -> Result<(), SendError<T>>
[src]
Attempts to send a value on this channel, returning it back if it could not be sent.
A successful send occurs when it is determined that the other end of the channel has not hung up already. An unsuccessful send would be one where the corresponding receiver has already been deallocated. Note that a return value of Err means that the data will never be received, but a return value of Ok does not mean that the data will be received. It is possible for the corresponding receiver to hang up immediately after this function returns Ok.
This function will block the current thread until the channel has capacity to accept the value or there are no more receivers to accept the value.
fn send_timeout(
&self,
t: T,
timeout: Duration
) -> Result<(), SendTimeoutError<T>>
[src]
&self,
t: T,
timeout: Duration
) -> Result<(), SendTimeoutError<T>>
Attempts to send a value on this channel, blocking for at most
timeout
.
The function will always block the current thread if the channel has no
available capacity for handling the message. The thread will be blocked
for at most timeout
, after which, if there still is no capacity,
SendTimeoutError::Timeout
will be returned.
fn try_send(&self, t: T) -> Result<(), TrySendError<T>>
[src]
Attempts to send a value on this channel without blocking.
This method differs from send
by returning immediately if the channel's
buffer is full or no receiver is waiting to acquire some data. Compared
with send
, this function has two failure cases instead of one (one for
disconnection, one for a full buffer).
See Sender::send
for notes about guarantees of whether the receiver
has received the data or not if this function is successful.
fn len(&self) -> usize
[src]
Returns the number of values currently buffered by the channel
fn close(&self)
[src]
Fully close the channel
This will force close the channel even if there are outstanding Sender
and Receiver
handles. Further operations on any outstanding handle
will result in a disconnected error.
fn is_open(&self) -> bool
[src]
Returns true
if the channel is currently in an open state
fn capacity(&self) -> usize
[src]
Returns the capacity of the queue
use two_lock_queue::{channel, unbounded}; let (tx, _) = channel(1024); assert_eq!(tx.capacity(), 1024); let (tx, _) = unbounded(); assert_eq!(tx.capacity(), usize::MAX);
Trait Implementations
impl<T> Clone for Sender<T>
[src]
fn clone(&self) -> Sender<T>
[src]
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more