diff options
| author | Cobrand <cobrandw@gmail.com> | 2016-11-22 21:55:02 +0100 |
|---|---|---|
| committer | Cobrand <cobrandw@gmail.com> | 2016-12-07 18:57:01 +0100 |
| commit | 57f998a4602c2925d34d51a3961ba12edf54b967 (patch) | |
| tree | e9a357c8fe03918ecc6300cc41a83449bcfc2e44 /src/libstd | |
| parent | 7e39c0ede524e491cfd1898649115e03d4b22b53 (diff) | |
| download | rust-57f998a4602c2925d34d51a3961ba12edf54b967.tar.gz rust-57f998a4602c2925d34d51a3961ba12edf54b967.zip | |
Improve and fix mpsc documentation
Closes #37915 This commit enhances documentation with several links and fixes an error in the `sync_channel` documentation as well: `send` doesn't panic when the senders are all disconnected
Diffstat (limited to 'src/libstd')
| -rw-r--r-- | src/libstd/sync/mpsc/mod.rs | 29 |
1 files changed, 20 insertions, 9 deletions
diff --git a/src/libstd/sync/mpsc/mod.rs b/src/libstd/sync/mpsc/mod.rs index ca6e46eb15a..9f51d3e87f3 100644 --- a/src/libstd/sync/mpsc/mod.rs +++ b/src/libstd/sync/mpsc/mod.rs @@ -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 /// /// ``` @@ -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 /// |
