Skip to content

Commit 79e8a70

Browse files
committedDec 18, 2016
Add missing urls for thread doc module
1 parent ace092f commit 79e8a70

File tree

1 file changed

+38
-24
lines changed

1 file changed

+38
-24
lines changed
 

‎src/libstd/thread/mod.rs

+38-24
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,11 @@
1717
//! provide some built-in support for low-level synchronization.
1818
//!
1919
//! Communication between threads can be done through
20-
//! [channels](../../std/sync/mpsc/index.html), Rust's message-passing
21-
//! types, along with [other forms of thread
20+
//! [channels], Rust's message-passing types, along with [other forms of thread
2221
//! synchronization](../../std/sync/index.html) and shared-memory data
2322
//! structures. In particular, types that are guaranteed to be
2423
//! threadsafe are easily shared between threads using the
25-
//! atomically-reference-counted container,
26-
//! [`Arc`](../../std/sync/struct.Arc.html).
24+
//! atomically-reference-counted container, [`Arc`].
2725
//!
2826
//! Fatal logic errors in Rust cause *thread panic*, during which
2927
//! a thread will unwind the stack, running destructors and freeing
@@ -40,7 +38,7 @@
4038
//!
4139
//! ## Spawning a thread
4240
//!
43-
//! A new thread can be spawned using the `thread::spawn` function:
41+
//! A new thread can be spawned using the [`thread::spawn`][`spawn`] function:
4442
//!
4543
//! ```rust
4644
//! use std::thread;
@@ -55,7 +53,7 @@
5553
//! it), unless this parent is the main thread.
5654
//!
5755
//! The parent thread can also wait on the completion of the child
58-
//! thread; a call to `spawn` produces a `JoinHandle`, which provides
56+
//! thread; a call to [`spawn`] produces a [`JoinHandle`], which provides
5957
//! a `join` method for waiting:
6058
//!
6159
//! ```rust
@@ -68,13 +66,13 @@
6866
//! let res = child.join();
6967
//! ```
7068
//!
71-
//! The `join` method returns a `Result` containing `Ok` of the final
72-
//! value produced by the child thread, or `Err` of the value given to
73-
//! a call to `panic!` if the child panicked.
69+
//! The [`join`] method returns a [`Result`] containing [`Ok`] of the final
70+
//! value produced by the child thread, or [`Err`] of the value given to
71+
//! a call to [`panic!`] if the child panicked.
7472
//!
7573
//! ## Configuring threads
7674
//!
77-
//! A new thread can be configured before it is spawned via the `Builder` type,
75+
//! A new thread can be configured before it is spawned via the [`Builder`] type,
7876
//! which currently allows you to set the name and stack size for the child thread:
7977
//!
8078
//! ```rust
@@ -88,43 +86,43 @@
8886
//!
8987
//! ## The `Thread` type
9088
//!
91-
//! Threads are represented via the `Thread` type, which you can get in one of
89+
//! Threads are represented via the [`Thread`] type, which you can get in one of
9290
//! two ways:
9391
//!
94-
//! * By spawning a new thread, e.g. using the `thread::spawn` function, and
95-
//! calling `thread()` on the `JoinHandle`.
96-
//! * By requesting the current thread, using the `thread::current` function.
92+
//! * By spawning a new thread, e.g. using the [`thread::spawn`][`spawn`]
93+
//! function, and calling [`thread()`] on the [`JoinHandle`].
94+
//! * By requesting the current thread, using the [`thread::current()`] function.
9795
//!
98-
//! The `thread::current()` function is available even for threads not spawned
96+
//! The [`thread::current()`] function is available even for threads not spawned
9997
//! by the APIs of this module.
10098
//!
10199
//! ## Blocking support: park and unpark
102100
//!
103101
//! Every thread is equipped with some basic low-level blocking support, via the
104-
//! `thread::park()` function and `thread::Thread::unpark()` method. `park()`
105-
//! blocks the current thread, which can then be resumed from another thread by
106-
//! calling the `unpark()` method on the blocked thread's handle.
102+
//! [`thread::park()`][`park()`] function and [`thread::Thread::unpark()`][`unpark()`]
103+
//! method. [`park()`] blocks the current thread, which can then be resumed from
104+
//! another thread by calling the [`unpark()`] method on the blocked thread's handle.
107105
//!
108-
//! Conceptually, each `Thread` handle has an associated token, which is
106+
//! Conceptually, each [`Thread`] handle has an associated token, which is
109107
//! initially not present:
110108
//!
111-
//! * The `thread::park()` function blocks the current thread unless or until
109+
//! * The [`thread::park()`][`park()`] function blocks the current thread unless or until
112110
//! the token is available for its thread handle, at which point it atomically
113111
//! consumes the token. It may also return *spuriously*, without consuming the
114-
//! token. `thread::park_timeout()` does the same, but allows specifying a
112+
//! token. [`thread::park_timeout()`] does the same, but allows specifying a
115113
//! maximum time to block the thread for.
116114
//!
117-
//! * The `unpark()` method on a `Thread` atomically makes the token available
115+
//! * The [`unpark()`] method on a [`Thread`] atomically makes the token available
118116
//! if it wasn't already.
119117
//!
120-
//! In other words, each `Thread` acts a bit like a semaphore with initial count
118+
//! In other words, each [`Thread`] acts a bit like a semaphore with initial count
121119
//! 0, except that the semaphore is *saturating* (the count cannot go above 1),
122120
//! and can return spuriously.
123121
//!
124122
//! The API is typically used by acquiring a handle to the current thread,
125123
//! placing that handle in a shared data structure so that other threads can
126124
//! find it, and then `park`ing. When some desired condition is met, another
127-
//! thread calls `unpark` on the handle.
125+
//! thread calls [`unpark()`] on the handle.
128126
//!
129127
//! The motivation for this design is twofold:
130128
//!
@@ -149,6 +147,22 @@
149147
//! will want to make use of some form of **interior mutability** through the
150148
//! [`Cell`] or [`RefCell`] types.
151149
//!
150+
//! [channels]: ../../std/sync/mpsc/index.html
151+
//! [`Arc`]: ../../std/sync/struct.Arc.html
152+
//! [`spawn`]: ../../std/thread/fn.spawn.html
153+
//! [`JoinHandle`]: ../../std/thread/struct.JoinHandle.html
154+
//! [`thread()`]: ../../std/thread/struct.JoinHandle.html#method.thread
155+
//! [`join`]: ../../std/thread/struct.JoinHandle.html#method.join
156+
//! [`Result`]: ../../std/result/enum.Result.html
157+
//! [`Ok`]: ../../std/result/enum.Result.html#variant.Ok
158+
//! [`Err`]: ../../std/result/enum.Result.html#variant.Err
159+
//! [`panic!`]: ../../std/macro.panic.html
160+
//! [`Builder`]: ../../std/thread/struct.Builder.html
161+
//! [`thread::current()`]: ../../std/thread/fn.spawn.html
162+
//! [`Thread`]: ../../std/thread/struct.Thread.html
163+
//! [`park()`]: ../../std/thread/fn.park.html
164+
//! [`unpark()`]: ../../std/thread/struct.Thread.html#method.unpark
165+
//! [`thread::park_timeout()`]: ../../std/thread/fn.park_timeout.html
152166
//! [`Cell`]: ../cell/struct.Cell.html
153167
//! [`RefCell`]: ../cell/struct.RefCell.html
154168
//! [`thread_local!`]: ../macro.thread_local.html

0 commit comments

Comments
 (0)
Please sign in to comment.