[−][src]Struct per_thread_object::ThreadLocal
Per-object thread-local storage
Cloneable
ThreadLocal uses built-in reference counting,
so it is usually not necessary to use Arc.
Capacity
per-thread-object has no capacity limit,
each ThreadLocal instance will create its own memory space
instead of using global space.
this crate supports any number of threads, but only the N threads are lock-free.
Panic when dropping
ThreadLocal will release object when calling clean or the end of thread.
If panic occurs during this process, it may cause a memory leak.
Implementations
impl<T: 'static> ThreadLocal<T>[src]
pub fn new() -> ThreadLocal<T>[src]
pub fn get(&self) -> Option<&T>[src]
pub fn get_or<F: FnOnce() -> T>(&self, f: F) -> &T[src]
pub fn get_or_try<F, E>(&self, f: F) -> Result<&T, E> where
F: FnOnce() -> Result<T, E>, [src]
F: FnOnce() -> Result<T, E>,
pub fn clean(&self)[src]
Deprecated since 0.1.1:
please use take instead
Clean up the objects of this thread.
pub fn take(&self) -> Option<T>[src]
Take value from current thread.
Trait Implementations
impl<T: Clone + 'static> Clone for ThreadLocal<T>[src]
fn clone(&self) -> ThreadLocal<T>[src]
fn clone_from(&mut self, source: &Self)1.0.0[src]
impl<T: 'static> Default for ThreadLocal<T>[src]
fn default() -> ThreadLocal<T>[src]
impl<T> Send for ThreadLocal<T>[src]
impl<T> Sync for ThreadLocal<T>[src]
Auto Trait Implementations
impl<T> !RefUnwindSafe for ThreadLocal<T>
impl<T> Unpin for ThreadLocal<T>
impl<T> !UnwindSafe for ThreadLocal<T>
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized, [src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized, [src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized, [src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T[src]
impl<T> From<T> for T[src]
impl<T, U> Into<U> for T where
U: From<T>, [src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone, [src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T[src]
fn clone_into(&self, target: &mut T)[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>, [src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>, [src]
U: TryFrom<T>,