diff options
| author | Christian Poveda <z1mvader@protonmail.com> | 2017-04-26 11:54:17 -0500 |
|---|---|---|
| committer | Christian Poveda <z1mvader@protonmail.com> | 2017-04-26 11:54:17 -0500 |
| commit | cf521211a13ccb7e8ea25af97d0efc3abe6d9070 (patch) | |
| tree | c645782568054a61c86e8586b38c8fbcbaa0ae3a /src/libstd | |
| parent | bdb6bb9684e5cc874d69d6cd65be3d9fb1e64401 (diff) | |
| download | rust-cf521211a13ccb7e8ea25af97d0efc3abe6d9070.tar.gz rust-cf521211a13ccb7e8ea25af97d0efc3abe6d9070.zip | |
restructured docs for thread and added links
Diffstat (limited to 'src/libstd')
| -rw-r--r-- | src/libstd/thread/mod.rs | 32 |
1 files changed, 19 insertions, 13 deletions
diff --git a/src/libstd/thread/mod.rs b/src/libstd/thread/mod.rs index aa7ef2da0ae..4e49c485f10 100644 --- a/src/libstd/thread/mod.rs +++ b/src/libstd/thread/mod.rs @@ -713,28 +713,34 @@ struct Inner { #[derive(Clone)] #[stable(feature = "rust1", since = "1.0.0")] -/// A handle to a thread, its just an abstract reference and as such -/// it can be used to identify a thread (by name, for example). In most -/// usage cases, this struct is not used directly. +/// A handle to a thread. +/// +/// You can use it to identify a thread (by name, for example). Most of the +/// time, there is no need to directly create a `Thread` struct using the +/// constructor, instead you should use a function like `spawn` to create +/// new threads, see the docs of [`Builder`] and [`spawn`] for more. /// /// # Examples /// /// ``` -/// use std::thread; +/// use std::thread::Builder; /// /// for i in 0..5 { /// let thread_name = format!("thread_{}", i); -/// thread::Builder::new() -/// .name(thread_name) // Now you can identify which thread panicked -/// // thanks to the handle's name -/// .spawn(move || { -/// if i == 3 { -/// panic!("I'm scared!!!"); -/// } -/// }) -/// .unwrap(); +/// Builder::new() +/// .name(thread_name) // Now you can identify which thread panicked +/// // thanks to the handle's name +/// .spawn(move || { +/// if i == 3 { +/// panic!("I'm scared!!!"); +/// } +/// }) +/// .unwrap(); /// } /// ``` +/// [`Builder`]: ../../std/thread/struct.Builder.html +/// [`spawn`]: ../../std/thread/fn.spawn.html + pub struct Thread { inner: Arc<Inner>, } |
