Struct std::comm::SyncSenderUnstable
[-]
[+]
[src]
pub struct SyncSender<T> { // some fields omitted }
The sending-half of Rust's synchronous channel type. This half can only be owned by one task, but it can be cloned to send to other tasks.
Methods
impl<T: Send> SyncSender<T>
fn send(&self, t: T)
Sends a value on this synchronous channel.
This function will block until space in the internal buffer becomes available or a receiver is available to hand off the message to.
Note that a successful send does not guarantee that the receiver will ever see the data if there is a buffer on this channel. Messages may be enqueued in the internal buffer for the receiver to receive at a later time. If the buffer size is 0, however, it can be guaranteed that the receiver has indeed received the data if this function returns success.
Panics
Similarly to Sender::send
, this function will panic if the
corresponding Receiver
for this channel has disconnected. This
behavior is used to propagate panics among tasks.
If a panic is not desired, you can achieve the same semantics with the
SyncSender::send_opt
method which will not panic if the receiver
disconnects.
fn send_opt(&self, t: T) -> Result<(), T>
Send a value on a channel, returning it back if the receiver disconnected
This method will block to send the value t
on the channel, but if
the value could not be sent due to the receiver disconnecting, the value
is returned back to the callee. This function is similar to try_send
,
except that it will block if the channel is currently full.
Panics
This function cannot panic.
fn try_send(&self, t: T) -> Result<(), TrySendError<T>>
Attempts to send a value on this channel without blocking.
This method differs from send_opt
by returning immediately if the
channel's buffer is full or no receiver is waiting to acquire some
data. Compared with send_opt
, this function has two failure cases
instead of one (one for disconnection, one for a full buffer).
See SyncSender::send
for notes about guarantees of whether the
receiver has received the data or not if this function is successful.
Panics
This function cannot panic