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

Add links and some examples to std::sync::mpsc docs #40981

Merged
merged 5 commits into from
Apr 5, 2017

Conversation

Technius
Copy link
Contributor

@Technius Technius commented Apr 1, 2017

Addresses part of #29377
r? @steveklabnik

I took a stab at adding links to the std::sync::mpsc docs, and I also wrote a few examples.

Edit: Whoops, typed in ?r instead of r?.

This change adds links to to `Receiver`, `Iter`, `TryIter`, `IntoIter`,
`Sender`, `SyncSender`, `SendError`, `RecvError`, `TryRecvError`,
`RecvTimeoutError`, `TrySendError`, `Sender::send`, `SyncSender::send`,
`SyncSender::try_send`, `Receiver::recv`, `Receiver::recv_timeout`,
`Receiver::iter`, and `Receiver::try_iter`.

Examples added to `Receiver`, `Sender`, `Receiver::iter`.
@rust-highfive
Copy link
Collaborator

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @alexcrichton (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see the contribution instructions for more information.

@Technius Technius changed the title Add links to std::sync::mpsc docs Add links and some examples to std::sync::mpsc docs Apr 1, 2017
@alexcrichton
Copy link
Member

r? @steveklabnik

@frewsxcv
Copy link
Member

frewsxcv commented Apr 1, 2017

@frewsxcv frewsxcv added the A-docs Area: documentation for any part of the project, including the compiler, standard library, and tools label Apr 1, 2017
Copy link
Member

@steveklabnik steveklabnik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you so much! This is great, I just have a few minor style nits. We don't use ()s for function names, and some extra whitespace will make these examples more readable. Thank you!

//! senders are clone-able (multi-producer) such that many threads can send
//! simultaneously to one receiver (single-consumer).
//!
//! These channels come in two flavors:
//!
//! 1. An asynchronous, infinitely buffered channel. The `channel()` function
//! 1. An asynchronous, infinitely buffered channel. The [`channel()`] function
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know you're adapting existing text here, but the style is to drop the ()s. Would you mind doing that as well please?

//! 2. A synchronous, bounded channel. The `sync_channel()` function will return
//! a `(SyncSender, Receiver)` tuple where the storage for pending messages
//! is a pre-allocated buffer of a fixed size. All sends will be
//! 2. A synchronous, bounded channel. The [`sync_channel()`] function will
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

//! [`Receiver`]: ../../../std/sync/mpsc/struct.Receiver.html
//! [`send`]: ../../../std/sync/mpsc/struct.Sender.html#method.send
//! [`channel()`]: ../../../std/sync/mpsc/fn.channel.html
//! [`sync_channel()`]: ../../../std/sync/mpsc/fn.sync_channel.html
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and both of these lines to match

//! continue to `unwrap()` the results returned from this module, instigating a
//! propagation of failure among threads if one unexpectedly dies.
//! continue to make progress, so [`Err`] will be returned. Many applications
//! will continue to [`unwrap()`] the results returned from this module,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and here

//!
//! [`Result`]: ../../../std/result/enum.Result.html
//! [`Err`]: ../../../std/result/enum.Result.html#variant.Err
//! [`unwrap()`]: ../../../std/result/enum.Result.html#method.unwrap
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and here

/// thread::spawn(move || {
/// sender.send(1).unwrap();
/// });
/// // Second thread owns sender2
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and one above here

/// thread::spawn(move || {
/// sender2.send(2).unwrap();
/// });
/// let msg = receiver.recv().unwrap();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and one above here

/// });
/// let msg = receiver.recv().unwrap();
/// let msg2 = receiver.recv().unwrap();
/// assert_eq!(3, msg + msg2);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and one above here, please!

/// ```rust
/// use std::sync::mpsc::channel;
/// use std::thread;
/// let (send, recv) = channel();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

one blank line above and below this line, please!

/// send.send(2u8).unwrap();
/// send.send(3u8).unwrap();
/// });
/// for x in recv.iter() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and one above here

@steveklabnik
Copy link
Member

@bors: r+ rollup

Thanks!

@bors
Copy link
Contributor

bors commented Apr 4, 2017

📌 Commit ab4f442 has been approved by steveklabnik

frewsxcv added a commit to frewsxcv/rust that referenced this pull request Apr 4, 2017
Add links and some examples to std::sync::mpsc docs

Addresses part of rust-lang#29377
r? @steveklabnik

I took a stab at adding links to the `std::sync::mpsc` docs, and I also wrote a few examples.

Edit: Whoops, typed in `?r` instead of `r?`.
frewsxcv added a commit to frewsxcv/rust that referenced this pull request Apr 4, 2017
Add links and some examples to std::sync::mpsc docs

Addresses part of rust-lang#29377
r? @steveklabnik

I took a stab at adding links to the `std::sync::mpsc` docs, and I also wrote a few examples.

Edit: Whoops, typed in `?r` instead of `r?`.
frewsxcv added a commit to frewsxcv/rust that referenced this pull request Apr 5, 2017
Add links and some examples to std::sync::mpsc docs

Addresses part of rust-lang#29377
r? @steveklabnik

I took a stab at adding links to the `std::sync::mpsc` docs, and I also wrote a few examples.

Edit: Whoops, typed in `?r` instead of `r?`.
frewsxcv added a commit to frewsxcv/rust that referenced this pull request Apr 5, 2017
Add links and some examples to std::sync::mpsc docs

Addresses part of rust-lang#29377
r? @steveklabnik

I took a stab at adding links to the `std::sync::mpsc` docs, and I also wrote a few examples.

Edit: Whoops, typed in `?r` instead of `r?`.
bors added a commit that referenced this pull request Apr 5, 2017
@bors bors merged commit ab4f442 into rust-lang:master Apr 5, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-docs Area: documentation for any part of the project, including the compiler, standard library, and tools
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants