Struct alloc_tls::TLSSlot [] [src]

pub struct TLSSlot<T> { /* fields omitted */ }

A slot for a thread-local variable.

A TLSSlot should be initialized using the internal_thread_local! macro. See its documentation for details on declaring and using thread-local variables.

Methods

impl<T> TLSSlot<T>
[src]

[src]

Access the TLS slot.

with accepts a function that will be called with a reference to the TLS value. If the slot is in the initializing or dropped state, with will return None without invoking f. If the slot is in the uninitialized state, with will initialize the value and then call f. If the slot is in the initialized state, with will call f. In either of these last two cases, with will return Some(r), where r is the value returned from the call to f.

Safety

with is unsafe because if f panics, it causes undefined behavior.

Trait Implementations

impl<T> Sync for TLSSlot<T>
[src]