Uh oh!
There was an error while loading. Please reload this page.
[Doc] Expands detach documentation in thread::JoinHande. - #41981
Conversation
detach documentation in thread::JoinHande.detach documentation in thread::JoinHande.There was a problem hiding this comment.
The example could be simplified with a plain scope or function instead of spawning two threads.
There’s no parent-child relationship between the threads in a process.
There was a problem hiding this comment.
The example could indeed be simplified to
fnmain(){{
thread::spawn(||{
thread::sleep(Duration::from_millis(10));println!("hey");});}
thread::sleep(Duration::from_millis(1000));}But this is not a form that I have ever encountered in real rust code, thus this example would not be very helpful.
On the other hand a thread spawning a new thread and being joined before the new thread is a behaviour that is encountered in real rust code. It is thus a bit more complex than needed, but I believe that it is also more helpful.
There are indeed no parent-child relationship between thread, this just seemed a good illustration, if you have a better name in mind I'll change for it.
There was a problem hiding this comment.
Well, the current example seems fine to me. But if improvements are possible, I'm open to it as long as it's easy to understand for readers.
There was a problem hiding this comment.
Changed the child notation for spawned or associated.
On the other hand I still believe the current example to more helpful.
r? @rust-lang/docs |
There was a problem hiding this comment.
could you put an extra newline above here
There was a problem hiding this comment.
and below here, please? that is, an empty ///. This feels a bit cramped.
72f33b3 to
c60ec47Comparegamazeps
commented
May 16, 2017
Done :) |
Mark-Simulacrum
commented
May 20, 2017
@steveklabnik I think this is ready for another review and should be ready to go. |
There was a problem hiding this comment.
This should be marked no_run so we compile the code but don't run it during tests (we don't want this test to take a full second)
see also: https://doc.rust-lang.org/nightly/book/first-edition/documentation.html#running-documentation-tests
steveklabnik
left a comment
There was a problem hiding this comment.
r=me after the change @frewsxcv mentioned, thank you!
alexcrichton
commented
Jun 1, 2017
ping @gamazeps, just wanted to make sure this was still on your radar! |
gamazeps
commented
Jun 1, 2017
@alexcrichton and you were right to do so :) |
Part of rust-lang#29378 . - Adds an example of a thread detaching. - Expands what `detaching` means.
gamazeps
commented
Jun 2, 2017
Done :) |
frewsxcv
commented
Jun 2, 2017
@bors r+ rollup |
bors
commented
Jun 2, 2017
📌 Commit b76b9e1 has been approved by |
[Doc] Expands `detach` documentation in `thread::JoinHande`. Part of rust-lang#29378 . - Adds an example of a thread detaching. - Expands what `detaching` means. r? @steveklabnik
Part of #29378 .
detachingmeans.r? @steveklabnik