๐ฌThis is a nightly-only experimental API. (
thread_local_internals
)Expand description
Implementation of the thread_local
macro.
There are three different thread-local implementations:
- Some targets lack threading support, and hence have only one thread, so
the TLS data is stored in a normal
static
. - Some targets support TLS natively via the dynamic linker and C runtime.
- On some targets, the OS provides a library-based TLS implementation. The TLS data is heap-allocated and referenced using a TLS key.
Each implementation provides a macro which generates the LocalKey
const
used to reference the TLS variable, along with the necessary helper structs
to track the initialization/destruction state of the variable.
Additionally, this module contains abstractions for the OS interfaces used for these implementations.
Re-exportsยง
pub use native::EagerStorage;
Experimental pub use native::LazyStorage;
Experimental pub use native::thread_local_inner;
Experimental
Modulesยง
- destructors ๐
Experimental - The native TLS implementation needs a way to register destructors for its data. This module contains platform-specific implementations of that register.
- guard ๐
Experimental - This module provides a way to schedule the execution of the destructor list
and the runtime cleanup function. Calling
enable
should ensure that these functions are called at the right times. - key ๐
Experimental const
-creatable TLS keys.- native ๐
Experimental - Thread local support for platforms with native TLS.
Functionsยง
- abort_
on_ ๐dtor_ unwind Experimental - Run a callback in a scenario which must not unwind (such as a
extern "C" fn
declared in a user crate). If the callback unwinds anyway, thenrtabort
with a message about thread local panicking on drop.