diff options
| author | bors <bors@rust-lang.org> | 2016-09-06 16:45:41 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2016-09-06 16:45:41 -0700 |
| commit | 3b272bf3102afd739d3e7284b898fa42fa1bd64e (patch) | |
| tree | 9f67bd69a4b367cf1917eeecab56f048fc55994b /src/libstd/thread | |
| parent | 923bac45964940c56ab1075fb7980896de1eb620 (diff) | |
| parent | 20cce247e11f5fd84edc4861f59d614d805362e3 (diff) | |
| download | rust-3b272bf3102afd739d3e7284b898fa42fa1bd64e.tar.gz rust-3b272bf3102afd739d3e7284b898fa42fa1bd64e.zip | |
Auto merge of #36303 - jonathandturner:rollup, r=jonathandturner
Rollup of 8 pull requests - Successful merges: #36121, #36128, #36241, #36243, #36263, #36267, #36273, #36298 - Failed merges:
Diffstat (limited to 'src/libstd/thread')
| -rw-r--r-- | src/libstd/thread/mod.rs | 35 |
1 files changed, 15 insertions, 20 deletions
diff --git a/src/libstd/thread/mod.rs b/src/libstd/thread/mod.rs index e3f3f9dd6de..d8e021bb04f 100644 --- a/src/libstd/thread/mod.rs +++ b/src/libstd/thread/mod.rs @@ -135,29 +135,24 @@ //! //! ## Thread-local storage //! -//! This module also provides an implementation of thread local storage for Rust -//! programs. Thread local storage is a method of storing data into a global -//! variable which each thread in the program will have its own copy of. +//! This module also provides an implementation of thread-local storage for Rust +//! programs. Thread-local storage is a method of storing data into a global +//! variable that each thread in the program will have its own copy of. //! Threads do not share this data, so accesses do not need to be synchronized. //! -//! At a high level, this module provides two variants of storage: -//! -//! * Owned thread-local storage. This is a type of thread local key which -//! owns the value that it contains, and will destroy the value when the -//! thread exits. This variant is created with the `thread_local!` macro and -//! can contain any value which is `'static` (no borrowed pointers). -//! -//! * Scoped thread-local storage. This type of key is used to store a reference -//! to a value into local storage temporarily for the scope of a function -//! call. There are no restrictions on what types of values can be placed -//! into this key. -//! -//! Both forms of thread local storage provide an accessor function, `with`, -//! which will yield a shared reference to the value to the specified -//! closure. Thread-local keys only allow shared access to values as there is no -//! way to guarantee uniqueness if a mutable borrow was allowed. Most values +//! A thread-local key owns the value it contains and will destroy the value when the +//! thread exits. It is created with the [`thread_local!`] macro and can contain any +//! value that is `'static` (no borrowed pointers). It provides an accessor function, +//! [`with`], that yields a shared reference to the value to the specified +//! closure. Thread-local keys allow only shared access to values, as there would be no +//! way to guarantee uniqueness if mutable borrows were allowed. Most values //! will want to make use of some form of **interior mutability** through the -//! `Cell` or `RefCell` types. +//! [`Cell`] or [`RefCell`] types. +//! +//! [`Cell`]: ../cell/struct.Cell.html +//! [`RefCell`]: ../cell/struct.RefCell.html +//! [`thread_local!`]: ../macro.thread_local!.html +//! [`with`]: struct.LocalKey.html#method.with #![stable(feature = "rust1", since = "1.0.0")] |
