mirror of
https://github.com/rust-lang/rust.git
synced 2025-05-14 02:49:40 +00:00
Rollup merge of #75750 - poliorcetics:intra-links-std-thread, r=jyn514
Move to intra doc links for std::thread documentation Helps with #75080. @rustbot modify labels: T-doc, A-intra-doc-links, T-rustdoc r? @jyn514
This commit is contained in:
commit
2a7f868d7f
@ -71,9 +71,7 @@ use crate::fmt;
|
|||||||
/// not guard typically have a synthetic limit after which point no more
|
/// not guard typically have a synthetic limit after which point no more
|
||||||
/// destructors are run.
|
/// destructors are run.
|
||||||
///
|
///
|
||||||
/// [`with`]: ../../std/thread/struct.LocalKey.html#method.with
|
/// [`with`]: LocalKey::with
|
||||||
/// [`thread_local!`]: ../../std/macro.thread_local.html
|
|
||||||
/// [`Drop`]: ../../std/ops/trait.Drop.html
|
|
||||||
#[stable(feature = "rust1", since = "1.0.0")]
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
pub struct LocalKey<T: 'static> {
|
pub struct LocalKey<T: 'static> {
|
||||||
// This outer `LocalKey<T>` type is what's going to be stored in statics,
|
// This outer `LocalKey<T>` type is what's going to be stored in statics,
|
||||||
@ -118,10 +116,10 @@ impl<T: 'static> fmt::Debug for LocalKey<T> {
|
|||||||
/// # fn main() {}
|
/// # fn main() {}
|
||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
/// See [LocalKey documentation][`std::thread::LocalKey`] for more
|
/// See [`LocalKey` documentation][`std::thread::LocalKey`] for more
|
||||||
/// information.
|
/// information.
|
||||||
///
|
///
|
||||||
/// [`std::thread::LocalKey`]: ../std/thread/struct.LocalKey.html
|
/// [`std::thread::LocalKey`]: crate::thread::LocalKey
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
#[stable(feature = "rust1", since = "1.0.0")]
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
#[allow_internal_unstable(thread_local_internals)]
|
#[allow_internal_unstable(thread_local_internals)]
|
||||||
|
@ -129,30 +129,19 @@
|
|||||||
//!
|
//!
|
||||||
//! Note that the stack size of the main thread is *not* determined by Rust.
|
//! Note that the stack size of the main thread is *not* determined by Rust.
|
||||||
//!
|
//!
|
||||||
//! [channels]: ../../std/sync/mpsc/index.html
|
//! [channels]: crate::sync::mpsc
|
||||||
//! [`Arc`]: ../../std/sync/struct.Arc.html
|
//! [`join`]: JoinHandle::join
|
||||||
//! [`spawn`]: ../../std/thread/fn.spawn.html
|
//! [`Result`]: crate::result::Result
|
||||||
//! [`JoinHandle`]: ../../std/thread/struct.JoinHandle.html
|
//! [`Ok`]: crate::result::Result::Ok
|
||||||
//! [`JoinHandle::thread`]: ../../std/thread/struct.JoinHandle.html#method.thread
|
//! [`Err`]: crate::result::Result::Err
|
||||||
//! [`join`]: ../../std/thread/struct.JoinHandle.html#method.join
|
//! [`thread::current`]: current
|
||||||
//! [`Result`]: ../../std/result/enum.Result.html
|
//! [`thread::Result`]: Result
|
||||||
//! [`Ok`]: ../../std/result/enum.Result.html#variant.Ok
|
//! [`unpark`]: Thread::unpark
|
||||||
//! [`Err`]: ../../std/result/enum.Result.html#variant.Err
|
//! [`Thread::name`]: Thread::name
|
||||||
//! [`panic!`]: ../../std/macro.panic.html
|
//! [`thread::park_timeout`]: park_timeout
|
||||||
//! [`Builder`]: ../../std/thread/struct.Builder.html
|
//! [`Cell`]: crate::cell::Cell
|
||||||
//! [`Builder::stack_size`]: ../../std/thread/struct.Builder.html#method.stack_size
|
//! [`RefCell`]: crate::cell::RefCell
|
||||||
//! [`Builder::name`]: ../../std/thread/struct.Builder.html#method.name
|
//! [`with`]: LocalKey::with
|
||||||
//! [`thread::current`]: ../../std/thread/fn.current.html
|
|
||||||
//! [`thread::Result`]: ../../std/thread/type.Result.html
|
|
||||||
//! [`Thread`]: ../../std/thread/struct.Thread.html
|
|
||||||
//! [`park`]: ../../std/thread/fn.park.html
|
|
||||||
//! [`unpark`]: ../../std/thread/struct.Thread.html#method.unpark
|
|
||||||
//! [`Thread::name`]: ../../std/thread/struct.Thread.html#method.name
|
|
||||||
//! [`thread::park_timeout`]: ../../std/thread/fn.park_timeout.html
|
|
||||||
//! [`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")]
|
#![stable(feature = "rust1", since = "1.0.0")]
|
||||||
|
|
||||||
@ -245,12 +234,12 @@ pub use self::local::statik::Key as __StaticLocalKeyInner;
|
|||||||
/// handler.join().unwrap();
|
/// handler.join().unwrap();
|
||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
/// [`thread::spawn`]: ../../std/thread/fn.spawn.html
|
/// [`stack_size`]: Builder::stack_size
|
||||||
/// [`stack_size`]: ../../std/thread/struct.Builder.html#method.stack_size
|
/// [`name`]: Builder::name
|
||||||
/// [`name`]: ../../std/thread/struct.Builder.html#method.name
|
/// [`spawn`]: Builder::spawn
|
||||||
/// [`spawn`]: ../../std/thread/struct.Builder.html#method.spawn
|
/// [`thread::spawn`]: spawn
|
||||||
/// [`io::Result`]: ../../std/io/type.Result.html
|
/// [`io::Result`]: crate::io::Result
|
||||||
/// [`unwrap`]: ../../std/result/enum.Result.html#method.unwrap
|
/// [`unwrap`]: crate::result::Result::unwrap
|
||||||
/// [naming-threads]: ./index.html#naming-threads
|
/// [naming-threads]: ./index.html#naming-threads
|
||||||
/// [stack-size]: ./index.html#stack-size
|
/// [stack-size]: ./index.html#stack-size
|
||||||
#[stable(feature = "rust1", since = "1.0.0")]
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
@ -355,9 +344,7 @@ impl Builder {
|
|||||||
/// [`io::Result`] to capture any failure to create the thread at
|
/// [`io::Result`] to capture any failure to create the thread at
|
||||||
/// the OS level.
|
/// the OS level.
|
||||||
///
|
///
|
||||||
/// [`spawn`]: ../../std/thread/fn.spawn.html
|
/// [`io::Result`]: crate::io::Result
|
||||||
/// [`io::Result`]: ../../std/io/type.Result.html
|
|
||||||
/// [`JoinHandle`]: ../../std/thread/struct.JoinHandle.html
|
|
||||||
///
|
///
|
||||||
/// # Panics
|
/// # Panics
|
||||||
///
|
///
|
||||||
@ -443,11 +430,7 @@ impl Builder {
|
|||||||
/// handler.join().unwrap();
|
/// handler.join().unwrap();
|
||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
/// [`spawn`]: ../../std/thread/fn.spawn.html
|
/// [`io::Result`]: crate::io::Result
|
||||||
/// [`Builder::spawn`]: ../../std/thread/struct.Builder.html#method.spawn
|
|
||||||
/// [`io::Result`]: ../../std/io/type.Result.html
|
|
||||||
/// [`JoinHandle`]: ../../std/thread/struct.JoinHandle.html
|
|
||||||
/// [`JoinHandle::join`]: ../../std/thread/struct.JoinHandle.html#method.join
|
|
||||||
#[unstable(feature = "thread_spawn_unchecked", issue = "55132")]
|
#[unstable(feature = "thread_spawn_unchecked", issue = "55132")]
|
||||||
pub unsafe fn spawn_unchecked<'a, F, T>(self, f: F) -> io::Result<JoinHandle<T>>
|
pub unsafe fn spawn_unchecked<'a, F, T>(self, f: F) -> io::Result<JoinHandle<T>>
|
||||||
where
|
where
|
||||||
@ -513,7 +496,7 @@ impl Builder {
|
|||||||
/// the main thread finishes). Additionally, the join handle provides a [`join`]
|
/// the main thread finishes). Additionally, the join handle provides a [`join`]
|
||||||
/// method that can be used to join the child thread. If the child thread
|
/// method that can be used to join the child thread. If the child thread
|
||||||
/// panics, [`join`] will return an [`Err`] containing the argument given to
|
/// panics, [`join`] will return an [`Err`] containing the argument given to
|
||||||
/// [`panic`].
|
/// [`panic!`].
|
||||||
///
|
///
|
||||||
/// This will create a thread using default parameters of [`Builder`], if you
|
/// This will create a thread using default parameters of [`Builder`], if you
|
||||||
/// want to specify the stack size or the name of the thread, use this API
|
/// want to specify the stack size or the name of the thread, use this API
|
||||||
@ -600,15 +583,9 @@ impl Builder {
|
|||||||
/// println!("{}", result);
|
/// println!("{}", result);
|
||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
/// [`channels`]: ../../std/sync/mpsc/index.html
|
/// [`channels`]: crate::sync::mpsc
|
||||||
/// [`JoinHandle`]: ../../std/thread/struct.JoinHandle.html
|
/// [`join`]: JoinHandle::join
|
||||||
/// [`join`]: ../../std/thread/struct.JoinHandle.html#method.join
|
/// [`Err`]: crate::result::Result::Err
|
||||||
/// [`Err`]: ../../std/result/enum.Result.html#variant.Err
|
|
||||||
/// [`panic`]: ../../std/macro.panic.html
|
|
||||||
/// [`Builder::spawn`]: ../../std/thread/struct.Builder.html#method.spawn
|
|
||||||
/// [`Builder`]: ../../std/thread/struct.Builder.html
|
|
||||||
/// [`Send`]: ../../std/marker/trait.Send.html
|
|
||||||
/// [`Sync`]: ../../std/marker/trait.Sync.html
|
|
||||||
#[stable(feature = "rust1", since = "1.0.0")]
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
pub fn spawn<F, T>(f: F) -> JoinHandle<T>
|
pub fn spawn<F, T>(f: F) -> JoinHandle<T>
|
||||||
where
|
where
|
||||||
@ -673,11 +650,8 @@ pub fn current() -> Thread {
|
|||||||
/// thread::yield_now();
|
/// thread::yield_now();
|
||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
/// [`channel`]: ../../std/sync/mpsc/index.html
|
/// [`channel`]: crate::sync::mpsc
|
||||||
/// [`spawn`]: ../../std/thread/fn.spawn.html
|
/// [`join`]: JoinHandle::join
|
||||||
/// [`join`]: ../../std/thread/struct.JoinHandle.html#method.join
|
|
||||||
/// [`Mutex`]: ../../std/sync/struct.Mutex.html
|
|
||||||
/// [`Condvar`]: ../../std/sync/struct.Condvar.html
|
|
||||||
#[stable(feature = "rust1", since = "1.0.0")]
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
pub fn yield_now() {
|
pub fn yield_now() {
|
||||||
imp::Thread::yield_now()
|
imp::Thread::yield_now()
|
||||||
@ -723,8 +697,6 @@ pub fn yield_now() {
|
|||||||
/// panic!()
|
/// panic!()
|
||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
///
|
|
||||||
/// [Mutex]: ../../std/sync/struct.Mutex.html
|
|
||||||
#[inline]
|
#[inline]
|
||||||
#[stable(feature = "rust1", since = "1.0.0")]
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
pub fn panicking() -> bool {
|
pub fn panicking() -> bool {
|
||||||
@ -881,10 +853,8 @@ const NOTIFIED: usize = 2;
|
|||||||
/// parked_thread.join().unwrap();
|
/// parked_thread.join().unwrap();
|
||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
/// [`Thread`]: ../../std/thread/struct.Thread.html
|
/// [`unpark`]: Thread::unpark
|
||||||
/// [`park`]: ../../std/thread/fn.park.html
|
/// [`thread::park_timeout`]: park_timeout
|
||||||
/// [`unpark`]: ../../std/thread/struct.Thread.html#method.unpark
|
|
||||||
/// [`thread::park_timeout`]: ../../std/thread/fn.park_timeout.html
|
|
||||||
//
|
//
|
||||||
// The implementation currently uses the trivial strategy of a Mutex+Condvar
|
// The implementation currently uses the trivial strategy of a Mutex+Condvar
|
||||||
// with wakeup flag, which does not actually allow spurious wakeups. In the
|
// with wakeup flag, which does not actually allow spurious wakeups. In the
|
||||||
@ -939,9 +909,6 @@ pub fn park() {
|
|||||||
/// amount of time waited to be precisely `ms` long.
|
/// amount of time waited to be precisely `ms` long.
|
||||||
///
|
///
|
||||||
/// See the [park documentation][`park`] for more detail.
|
/// See the [park documentation][`park`] for more detail.
|
||||||
///
|
|
||||||
/// [`park_timeout`]: fn.park_timeout.html
|
|
||||||
/// [`park`]: ../../std/thread/fn.park.html
|
|
||||||
#[stable(feature = "rust1", since = "1.0.0")]
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
#[rustc_deprecated(since = "1.6.0", reason = "replaced by `std::thread::park_timeout`")]
|
#[rustc_deprecated(since = "1.6.0", reason = "replaced by `std::thread::park_timeout`")]
|
||||||
pub fn park_timeout_ms(ms: u32) {
|
pub fn park_timeout_ms(ms: u32) {
|
||||||
@ -986,8 +953,6 @@ pub fn park_timeout_ms(ms: u32) {
|
|||||||
/// timeout_remaining = timeout - elapsed;
|
/// timeout_remaining = timeout - elapsed;
|
||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
///
|
|
||||||
/// [park]: fn.park.html
|
|
||||||
#[stable(feature = "park_timeout", since = "1.4.0")]
|
#[stable(feature = "park_timeout", since = "1.4.0")]
|
||||||
pub fn park_timeout(dur: Duration) {
|
pub fn park_timeout(dur: Duration) {
|
||||||
let thread = current();
|
let thread = current();
|
||||||
@ -1046,8 +1011,7 @@ pub fn park_timeout(dur: Duration) {
|
|||||||
/// assert!(thread::current().id() != other_thread_id);
|
/// assert!(thread::current().id() != other_thread_id);
|
||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
/// [`id`]: ../../std/thread/struct.Thread.html#method.id
|
/// [`id`]: Thread::id
|
||||||
/// [`Thread`]: ../../std/thread/struct.Thread.html
|
|
||||||
#[stable(feature = "thread_id", since = "1.19.0")]
|
#[stable(feature = "thread_id", since = "1.19.0")]
|
||||||
#[derive(Eq, PartialEq, Clone, Copy, Hash, Debug)]
|
#[derive(Eq, PartialEq, Clone, Copy, Hash, Debug)]
|
||||||
pub struct ThreadId(NonZeroU64);
|
pub struct ThreadId(NonZeroU64);
|
||||||
@ -1124,12 +1088,7 @@ struct Inner {
|
|||||||
/// should instead use a function like `spawn` to create new threads, see the
|
/// should instead use a function like `spawn` to create new threads, see the
|
||||||
/// docs of [`Builder`] and [`spawn`] for more details.
|
/// docs of [`Builder`] and [`spawn`] for more details.
|
||||||
///
|
///
|
||||||
/// [`Builder`]: ../../std/thread/struct.Builder.html
|
/// [`thread::current`]: current
|
||||||
/// [`JoinHandle::thread`]: ../../std/thread/struct.JoinHandle.html#method.thread
|
|
||||||
/// [`JoinHandle`]: ../../std/thread/struct.JoinHandle.html
|
|
||||||
/// [`thread::current`]: ../../std/thread/fn.current.html
|
|
||||||
/// [`spawn`]: ../../std/thread/fn.spawn.html
|
|
||||||
|
|
||||||
pub struct Thread {
|
pub struct Thread {
|
||||||
inner: Arc<Inner>,
|
inner: Arc<Inner>,
|
||||||
}
|
}
|
||||||
@ -1181,8 +1140,6 @@ impl Thread {
|
|||||||
///
|
///
|
||||||
/// parked_thread.join().unwrap();
|
/// parked_thread.join().unwrap();
|
||||||
/// ```
|
/// ```
|
||||||
///
|
|
||||||
/// [park]: fn.park.html
|
|
||||||
#[stable(feature = "rust1", since = "1.0.0")]
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
pub fn unpark(&self) {
|
pub fn unpark(&self) {
|
||||||
// To ensure the unparked thread will observe any writes we made
|
// To ensure the unparked thread will observe any writes we made
|
||||||
@ -1326,7 +1283,7 @@ impl fmt::Debug for Thread {
|
|||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
/// [`Result`]: ../../std/result/enum.Result.html
|
/// [`Result`]: crate::result::Result
|
||||||
#[stable(feature = "rust1", since = "1.0.0")]
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
pub type Result<T> = crate::result::Result<T, Box<dyn Any + Send + 'static>>;
|
pub type Result<T> = crate::result::Result<T, Box<dyn Any + Send + 'static>>;
|
||||||
|
|
||||||
@ -1421,9 +1378,8 @@ impl<T> JoinInner<T> {
|
|||||||
/// thread::sleep(Duration::from_millis(1000));
|
/// thread::sleep(Duration::from_millis(1000));
|
||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
/// [`Clone`]: ../../std/clone/trait.Clone.html
|
/// [`thread::Builder::spawn`]: Builder::spawn
|
||||||
/// [`thread::spawn`]: fn.spawn.html
|
/// [`thread::spawn`]: spawn
|
||||||
/// [`thread::Builder::spawn`]: struct.Builder.html#method.spawn
|
|
||||||
#[stable(feature = "rust1", since = "1.0.0")]
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
pub struct JoinHandle<T>(JoinInner<T>);
|
pub struct JoinHandle<T>(JoinInner<T>);
|
||||||
|
|
||||||
@ -1462,11 +1418,10 @@ impl<T> JoinHandle<T> {
|
|||||||
/// operations that happen after `join` returns.
|
/// operations that happen after `join` returns.
|
||||||
///
|
///
|
||||||
/// If the child thread panics, [`Err`] is returned with the parameter given
|
/// If the child thread panics, [`Err`] is returned with the parameter given
|
||||||
/// to [`panic`].
|
/// to [`panic!`].
|
||||||
///
|
///
|
||||||
/// [`Err`]: ../../std/result/enum.Result.html#variant.Err
|
/// [`Err`]: crate::result::Result::Err
|
||||||
/// [`panic`]: ../../std/macro.panic.html
|
/// [atomic memory orderings]: crate::sync::atomic
|
||||||
/// [atomic memory orderings]: ../../std/sync/atomic/index.html
|
|
||||||
///
|
///
|
||||||
/// # Panics
|
/// # Panics
|
||||||
///
|
///
|
||||||
|
Loading…
Reference in New Issue
Block a user