[][src]Struct per_thread_object::ThreadLocal

pub struct ThreadLocal<T: Send + 'static> { /* fields omitted */ }

Per-object thread-local storage

Capacity

per-thread-object has no max 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: Send + '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]

Trait Implementations

impl<T: Send + 'static> Default for ThreadLocal<T>[src]

impl<T: Send> Send for ThreadLocal<T>[src]

impl<T: Send> 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]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.