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

[Doc] Improve thread::spawn documentation #41854

Merged
merged 5 commits into from May 10, 2017

Conversation

gamazeps
Copy link
Contributor

@gamazeps gamazeps commented May 9, 2017

Part of #29378

  • Add two examples to thread::spawn doumentation that show common uses of threads.
  • Add a link to thread::Builder in the thread::spawn documentation for configuring threads.
  • Add a link to thread::spawn in thread::Builder in order to avoid documentation duplication.

r? @steveklabnik

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.

a few small changes please! Thanks for this, looks great!

@@ -409,6 +411,54 @@ impl Builder {
///
/// handler.join().unwrap();
/// ```
///
/// As mentionned in the module documentation, threads are usualy made to
/// communicate using [`channel`s][`channels`], here is how it usually looks.
Copy link
Member

Choose a reason for hiding this comment

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

this should work without the second set of []s by using the same text below

/// # Examples
///
/// Simple thread creation.
Copy link
Member

Choose a reason for hiding this comment

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

Could we say

Creating a thread:

instead here? I try to stick away from "simple" 😄

@gamazeps
Copy link
Contributor Author

gamazeps commented May 9, 2017

Done :)

@gamazeps gamazeps mentioned this pull request May 9, 2017
11 tasks
@steveklabnik
Copy link
Member

[01:06:47] failures:
[01:06:47] 
[01:06:47] ---- thread/mod.rs - thread::spawn (line 445) stdout ----
[01:06:47] 	error[E0425]: cannot find value `v` in this scope
[01:06:47]   --> <anon>:12:16
[01:06:47]    |
[01:06:47] 12 | println!("{}", v);
[01:06:47]    |                ^ not found in this scope
[01:06:47] 
[01:06:47] error: aborting due to previous error(s)
[01:06:47] 
[01:06:47] thread 'rustc' panicked at 'Box<Any>', /checkout/src/librustc/session/mod.rs:217
[01:06:47] note: Run with `RUST_BACKTRACE=1` for a backtrace.
[01:06:47] 
[01:06:47] ---- thread/mod.rs - thread::spawn (line 422) stdout ----
[01:06:47] 	error: unused result which must be used
[01:06:47]   --> <anon>:10:5
[01:06:47]    |
[01:06:47] 10 |     tx.send("Hello, thread".to_owned());
[01:06:47]    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[01:06:47]    |
[01:06:47]    = note: #[deny(unused_must_use)] implied by #[deny(warnings)]
[01:06:47] note: lint level defined here
[01:06:47]   --> <anon>:1:9
[01:06:47]    |
[01:06:47] 1  | #![deny(warnings)]
[01:06:47]    |         ^^^^^^^^
[01:06:47] 
[01:06:47] error: unused result which must be used
[01:06:47]   --> <anon>:17:1
[01:06:47]    |
[01:06:47] 17 | sender.join();
[01:06:47]    | ^^^^^^^^^^^^^^
[01:06:47]    |
[01:06:47]    = note: #[deny(unused_must_use)] implied by #[deny(warnings)]
[01:06:47] 
[01:06:47] error: unused result which must be used
[01:06:47]   --> <anon>:18:1
[01:06:47]    |
[01:06:47] 18 | receiver.join();
[01:06:47]    | ^^^^^^^^^^^^^^^^
[01:06:47]    |
[01:06:47]    = note: #[deny(unused_must_use)] implied by #[deny(warnings)]
[01:06:47] 
[01:06:47] error: aborting due to previous error(s)
[01:06:47] 
[01:06:47] thread 'rustc' panicked at 'Box<Any>', /checkout/src/librustc/session/mod.rs:217
[01:06:47] 
[01:06:47] 
[01:06:47] failures:
[01:06:47]     thread/mod.rs - thread::spawn (line 422)
[01:06:47]     thread/mod.rs - thread::spawn (line 445)
[01:06:47] 
[01:06:47] test result: FAILED. 797 passed; 2 failed; 22 ignored; 0 measured
[01:06:47] 
[01:06:47] error: test failed, to rerun pass '--doc'
[01:06:47] 
[01:06:47] 
[01:06:47] command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0/bin/cargo" "test" "-j" "4" "--target" "x86_64-unknown-linux-gnu" "--release" "--locked" "--manifest-path" "/checkout/src/libstd/Cargo.toml" "--features" "panic-unwind jemalloc backtrace" "-p" "std:0.0.0" "-p" "alloc_system:0.0.0" "-p" "libc:0.0.0" "-p" "compiler_builtins:0.0.0" "-p" "rustc_asan:0.0.0" "-p" "rustc_lsan:0.0.0" "-p" "unwind:0.0.0" "-p" "core:0.0.0" "-p" "rand:0.0.0" "-p" "rustc_msan:0.0.0" "-p" "panic_abort:0.0.0" "-p" "alloc:0.0.0" "-p" "collections:0.0.0" "-p" "rustc_tsan:0.0.0" "-p" "std_unicode:0.0.0" "--"
[01:06:47] expected success, got: exit code: 101
[01:06:47] 
[01:06:47] 
[01:06:47] Build completed unsuccessfully in 0:27:07
[01:06:47] Makefile:54: recipe for target 'check' failed
[01:06:47] make: *** [check] Error 1

once this is fixed we should be good to go!

@gamazeps
Copy link
Contributor Author

gamazeps commented May 9, 2017

Done :)

@@ -409,6 +411,54 @@ impl Builder {
///
/// handler.join().unwrap();
/// ```
///
/// As mentionned in the module documentation, threads are usualy made to
Copy link
Contributor

Choose a reason for hiding this comment

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

s/mentionned/mentioned/
s/usualy/usually/

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done :)

@steveklabnik
Copy link
Member

@bors: r+ rollup

@bors
Copy link
Contributor

bors commented May 10, 2017

📌 Commit fe7b6db has been approved by steveklabnik

steveklabnik added a commit to steveklabnik/rust that referenced this pull request May 10, 2017
…labnik

[Doc] Improve `thread::spawn` documentation

Part of rust-lang#29378

- Add two examples to `thread::spawn` doumentation that show common uses of threads.
- Add a link to `thread::Builder` in the `thread::spawn` documentation for configuring threads.
- Add a link to `thread::spawn` in `thread::Builder` in order to avoid documentation duplication.

r? @steveklabnik
bors added a commit that referenced this pull request May 10, 2017
Rollup of 5 pull requests

- Successful merges: #41531, #41536, #41809, #41854, #41886
- Failed merges:
@bors bors merged commit fe7b6db into rust-lang:master May 10, 2017
@gamazeps gamazeps deleted the thread-spawn-doc branch May 13, 2017 17:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants