std: update TLS module documentation · model-checking/verify-rust-std@2b9a4f3 (original) (raw)
1
``
`` -
//! An implementation of const
-creatable TLS keys for non-Windows platforms.
``
``
1
`` +
//! A StaticKey
implementation using racy initialization.
``
2
2
`//!
`
3
``
`-
//! Most OSs without native TLS will provide a library-based way to create TLS
`
4
``
`-
//! storage. For each TLS variable, we create a key, which can then be used to
`
5
``
`-
//! reference an entry in a thread-local table. This then associates each key
`
6
``
`-
//! with a pointer which we can get and set to store our data.
`
7
``
`-
//!
`
8
``
`-
//! Unfortunately, none of these platforms allows creating the key at compile-time,
`
9
``
`` -
//! which means we need a way to lazily create keys (StaticKey
). Instead of
``
10
``
`` -
//! blocking API like OnceLock
, we use racy initialization, which should be
``
11
``
`` -
//! more lightweight and avoids circular dependencies with the rest of std
.
``
``
3
`` +
//! Unfortunately, none of the platforms currently supported by std
allows
``
``
4
`+
//! creating TLS keys at compile-time. Thus we need a way to lazily create keys.
`
``
5
`` +
//! Instead of blocking API like OnceLock
, we use racy initialization, which
``
``
6
`+
//! should be more lightweight and avoids circular dependencies with the rest of
`
``
7
`` +
//! std
.
``
12
8
``
13
9
`use crate::sync::atomic::{self, AtomicUsize, Ordering};
`
14
10
``