Struct thread_local_object::ThreadLocal
[−]
[src]
pub struct ThreadLocal<T: 'static> { /* fields omitted */ }
A thread local variable wrapper.
Methods
impl<T: 'static> ThreadLocal<T>
[src]
fn new() -> ThreadLocal<T>
Creates a new ThreadLocal
with no values for any threads.
Panics
Panics if more than usize::max_value()
ThreadLocal
objects have already been created.
This can only ever realistically happen on 32 bit platforms.
fn set(&self, value: T) -> Option<T>
Sets this thread's value, returning the previous value if present.
Panics
Panics if called from within the execution of a closure provided to another method on this value.
fn remove(&self) -> Option<T>
Removes this thread's value, returning it if it existed.
Panics
Panics if called from within the execution of a closure provided to another method on this value.
fn entry<F, R>(&self, f: F) -> R where
F: FnOnce(Entry<T>) -> R,
F: FnOnce(Entry<T>) -> R,
Passes a handle to the current thread's value to a closure for in-place manipulation.
The closure is required for the same soundness reasons it is required for the standard
library's thread_local!
values.
Panics
Panics if called from within the execution of a closure provided to another method on this value.
fn get<F, R>(&self, f: F) -> R where
F: FnOnce(Option<&T>) -> R,
F: FnOnce(Option<&T>) -> R,
Passes a mutable reference to the current thread's value to a closure.
The closure is required for the same soundness reasons it is required for the standard
library's thread_local!
values.
Panics
Panics if called from within the execution of a closure passed to entry
or get_mut
on
this value.
fn get_mut<F, R>(&self, f: F) -> R where
F: FnOnce(Option<&mut T>) -> R,
F: FnOnce(Option<&mut T>) -> R,
Passes a mutable reference to the current thread's value to a closure.
The closure is required for the same soundness reasons it is required for the standard
library's thread_local!
values.
Panics
Panics if called from within the execution of a closure provided to another method on this value.
impl<T> ThreadLocal<T> where
T: 'static + Clone,
[src]
T: 'static + Clone,
fn get_cloned(&self) -> Option<T>
Returns a copy of the current thread's value.
Panics
Panics if called from within the execution of a closure passed to entry
or get_mut
on
this value.