Skip to main content

thread_local_cache

Macro thread_local_cache 

Source
macro_rules! thread_local_cache {
    (static $name:ident : $ty:ty) => { ... };
}
Expand description

Declare a thread-local slot for use with Cached.

thread_local_cache!(static SLOT: MyType);

Expands to a thread_local! declaration wrapping RefCell<(bool, Option<MyType>)> where:

  • (false, None) means uninitialized
  • (false, Some(_)) means available
  • (true, None) means held