Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve and fix mpsc documentation #37941

Merged
merged 1 commit into from
Dec 13, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 20 additions & 9 deletions src/libstd/sync/mpsc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -454,10 +454,16 @@ impl<T> UnsafeFlavor<T> for Receiver<T> {
}

/// Creates a new asynchronous channel, returning the sender/receiver halves.
///
/// All data sent on the sender will become available on the receiver, and no
/// send will block the calling thread (this channel has an "infinite buffer").
///
/// If the [`Receiver`] is disconnected while trying to [`send()`] with the
/// [`Sender`], the [`send()`] method will return an error.
///
/// [`send()`]: ../../../std/sync/mpsc/struct.Sender.html#method.send
/// [`Sender`]: ../../../std/sync/mpsc/struct.Sender.html
/// [`Receiver`]: ../../../std/sync/mpsc/struct.Receiver.html
///
/// # Examples
///
/// ```
Expand Down Expand Up @@ -487,18 +493,23 @@ pub fn channel<T>() -> (Sender<T>, Receiver<T>) {

/// Creates a new synchronous, bounded channel.
///
/// Like asynchronous channels, the `Receiver` will block until a message
/// Like asynchronous channels, the [`Receiver`] will block until a message
/// becomes available. These channels differ greatly in the semantics of the
/// sender from asynchronous channels, however.
///
/// This channel has an internal buffer on which messages will be queued. `bound`
/// specifies the buffer size. When the internal buffer becomes full, future sends
/// will *block* waiting for the buffer to open up. Note that a buffer size of 0
/// is valid, in which case this becomes "rendezvous channel" where each send will
/// not return until a recv is paired with it.
/// This channel has an internal buffer on which messages will be queued.
/// `bound` specifies the buffer size. When the internal buffer becomes full,
/// future sends will *block* waiting for the buffer to open up. Note that a
/// buffer size of 0 is valid, in which case this becomes "rendezvous channel"
/// where each [`send()`] will not return until a recv is paired with it.
///
/// Like asynchronous channels, if the [`Receiver`] is disconnected while
/// trying to [`send()`] with the [`SyncSender`], the [`send()`] method will
/// return an error.
///
/// As with asynchronous channels, all senders will panic in `send` if the
/// `Receiver` has been destroyed.
/// [`send()`]: ../../../std/sync/mpsc/struct.SyncSender.html#method.send
/// [`SyncSender`]: ../../../std/sync/mpsc/struct.SyncSender.html
/// [`Receiver`]: ../../../std/sync/mpsc/struct.Receiver.html
///
/// # Examples
///
Expand Down