Struct thread_local::ThreadLocal
[−]
[src]
Thread-local variable wrapper
See the module-level documentation for more.
Methods
impl<T: ?Sized + Send> ThreadLocal<T>
[src]
impl<T: ?Sized + Send> ThreadLocal<T>
pub fn new() -> ThreadLocal<T>
[src]
pub fn new() -> ThreadLocal<T>
Creates a new empty ThreadLocal
.
pub fn get(&self) -> Option<&T>
[src]
pub fn get(&self) -> Option<&T>
Returns the element for the current thread, if it exists.
ⓘImportant traits for &'a mut Rpub fn get_or<F>(&self, create: F) -> &T where
F: FnOnce() -> Box<T>,
[src]
pub fn get_or<F>(&self, create: F) -> &T where
F: FnOnce() -> Box<T>,
Returns the element for the current thread, or creates it if it doesn't exist.
pub fn get_or_try<F, E>(&self, create: F) -> Result<&T, E> where
F: FnOnce() -> Result<Box<T>, E>,
[src]
pub fn get_or_try<F, E>(&self, create: F) -> Result<&T, E> where
F: FnOnce() -> Result<Box<T>, E>,
Returns the element for the current thread, or creates it if it doesn't
exist. If create
fails, that error is returned and no element is
added.
ⓘImportant traits for IterMut<'a, T>pub fn iter_mut(&mut self) -> IterMut<T>
[src]
pub fn iter_mut(&mut self) -> IterMut<T>
Returns a mutable iterator over the local values of all threads.
Since this call borrows the ThreadLocal
mutably, this operation can
be done safely---the mutable borrow statically guarantees no other
threads are currently accessing their associated values.
pub fn clear(&mut self)
[src]
pub fn clear(&mut self)
Removes all thread-specific values from the ThreadLocal
, effectively
reseting it to its original state.
Since this call borrows the ThreadLocal
mutably, this operation can
be done safely---the mutable borrow statically guarantees no other
threads are currently accessing their associated values.
impl<T: Send + Default> ThreadLocal<T>
[src]
impl<T: Send + Default> ThreadLocal<T>
ⓘImportant traits for &'a mut Rpub fn get_default(&self) -> &T
[src]
pub fn get_default(&self) -> &T
Returns the element for the current thread, or creates a default one if it doesn't exist.
Trait Implementations
impl<T: ?Sized + Send> Sync for ThreadLocal<T>
[src]
impl<T: ?Sized + Send> Sync for ThreadLocal<T>
impl<T: ?Sized + Send> Default for ThreadLocal<T>
[src]
impl<T: ?Sized + Send> Default for ThreadLocal<T>
fn default() -> ThreadLocal<T>
[src]
fn default() -> ThreadLocal<T>
Returns the "default value" for a type. Read more
impl<T: ?Sized + Send> Drop for ThreadLocal<T>
[src]
impl<T: ?Sized + Send> Drop for ThreadLocal<T>
impl<T: ?Sized + Send> IntoIterator for ThreadLocal<T>
[src]
impl<T: ?Sized + Send> IntoIterator for ThreadLocal<T>
type Item = Box<T>
The type of the elements being iterated over.
type IntoIter = IntoIter<T>
Which kind of iterator are we turning this into?
ⓘImportant traits for IntoIter<T>fn into_iter(self) -> IntoIter<T>
[src]
fn into_iter(self) -> IntoIter<T>
Creates an iterator from a value. Read more
impl<'a, T: ?Sized + Send + 'a> IntoIterator for &'a mut ThreadLocal<T>
[src]
impl<'a, T: ?Sized + Send + 'a> IntoIterator for &'a mut ThreadLocal<T>
type Item = &'a mut Box<T>
The type of the elements being iterated over.
type IntoIter = IterMut<'a, T>
Which kind of iterator are we turning this into?
ⓘImportant traits for IterMut<'a, T>fn into_iter(self) -> IterMut<'a, T>
[src]
fn into_iter(self) -> IterMut<'a, T>
Creates an iterator from a value. Read more
impl<T: ?Sized + Send + Debug> Debug for ThreadLocal<T>
[src]
impl<T: ?Sized + Send + Debug> Debug for ThreadLocal<T>
fn fmt(&self, f: &mut Formatter) -> Result
[src]
fn fmt(&self, f: &mut Formatter) -> Result
Formats the value using the given formatter. Read more
impl<T: ?Sized + Send + UnwindSafe> UnwindSafe for ThreadLocal<T>
[src]
impl<T: ?Sized + Send + UnwindSafe> UnwindSafe for ThreadLocal<T>
Auto Trait Implementations
impl<T: ?Sized> Send for ThreadLocal<T>
impl<T: ?Sized> Send for ThreadLocal<T>