Module thread_local
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.
Modules
- destructors The native TLS implementation needs a way to register destructors for its data. This module contains platform-specific implementations of that register.
-
guard
This module provides a way to schedule the execution of the destructor list
and the runtime cleanup function. Calling
enablesets up the current thread to ensure that these functions are called at the right times. -
key
const-creatable TLS keys. - native Thread local support for platforms with native TLS.
Structs
Functions
-
abort_on_dtor_unwind
Run a callback in a scenario which must not unwind (such as a
extern "C" fndeclared in a user crate). If the callback unwinds anyway, thenrtabortwith a message about thread local panicking on drop.