From 6e848be5f8071f1fe6110b3ec2bee0776126f79b Mon Sep 17 00:00:00 2001 From: Corey Farwell Date: Thu, 23 Jun 2016 18:16:37 -0400 Subject: [PATCH 1/2] Indicate how the `JoinHandle` struct is created. --- src/libstd/thread/mod.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/libstd/thread/mod.rs b/src/libstd/thread/mod.rs index 1f78b32bcf38e..355e0f50cef35 100644 --- a/src/libstd/thread/mod.rs +++ b/src/libstd/thread/mod.rs @@ -610,6 +610,12 @@ impl JoinInner { /// Due to platform restrictions, it is not possible to `Clone` this /// handle: the ability to join a child thread is a uniquely-owned /// permission. +/// +/// This `struct` is created by the [`thread::spawn`] function and the +/// [`thread::Builder::spawn`] method. +/// +/// [`thread::spawn`]: fn.spawn.html +/// [`thread::Builder::spawn`]: struct.Builder.html#method.spawn #[stable(feature = "rust1", since = "1.0.0")] pub struct JoinHandle(JoinInner); From 5e9b75e2dd440a5df2c7d90f88b2660c7581d964 Mon Sep 17 00:00:00 2001 From: Corey Farwell Date: Fri, 24 Jun 2016 08:12:58 -0400 Subject: [PATCH 2/2] Add examples in docs for `JoinHandle`. --- src/libstd/thread/mod.rs | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/libstd/thread/mod.rs b/src/libstd/thread/mod.rs index 355e0f50cef35..26085c86813ad 100644 --- a/src/libstd/thread/mod.rs +++ b/src/libstd/thread/mod.rs @@ -614,6 +614,30 @@ impl JoinInner { /// This `struct` is created by the [`thread::spawn`] function and the /// [`thread::Builder::spawn`] method. /// +/// # Examples +/// +/// Creation from [`thread::spawn`]: +/// +/// ```rust +/// use std::thread; +/// +/// let join_handle: thread::JoinHandle<_> = thread::spawn(|| { +/// // some work here +/// }); +/// ``` +/// +/// Creation from [`thread::Builder::spawn`]: +/// +/// ```rust +/// use std::thread; +/// +/// let builder = thread::Builder::new(); +/// +/// let join_handle: thread::JoinHandle<_> = builder.spawn(|| { +/// // some work here +/// }).unwrap(); +/// ``` +/// /// [`thread::spawn`]: fn.spawn.html /// [`thread::Builder::spawn`]: struct.Builder.html#method.spawn #[stable(feature = "rust1", since = "1.0.0")]