std::thread_local!
[−]
[src]
macro_rules! thread_local { (static $name:ident: $t:ty = $init:expr) => ( static $name: ::std::thread::LocalKey<$t> = { #[cfg_attr(all(any(target_os = "macos", target_os = "linux"), not(target_arch = "aarch64")), thread_local)] static __KEY: ::std::thread::__LocalKeyInner<$t> = ::std::thread::__LocalKeyInner::new(); fn __init() -> $t { $init } fn __getit() -> &'static ::std::thread::__LocalKeyInner<$t> { &__KEY } ::std::thread::LocalKey::new(__getit, __init) }; ); (pub static $name:ident: $t:ty = $init:expr) => ( pub static $name: ::std::thread::LocalKey<$t> = { #[cfg_attr(all(any(target_os = "macos", target_os = "linux"), not(target_arch = "aarch64")), thread_local)] static __KEY: ::std::thread::__LocalKeyInner<$t> = ::std::thread::__LocalKeyInner::new(); fn __init() -> $t { $init } fn __getit() -> &'static ::std::thread::__LocalKeyInner<$t> { &__KEY } ::std::thread::LocalKey::new(__getit, __init) }; ); }
Declare a new thread local storage key of type std::thread::LocalKey
.
See LocalKey documentation for more information.