[][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 DEFAULT_PAGE_CAP threads are lock-free.

Panic when dropping

ThreadLocal will release object at 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 with<F, R>(&self, f: F) -> R where
    F: FnOnce(&T) -> R, 
[src]

pub fn try_with<F, R>(&self, f: F) -> Option<R> where
    F: FnOnce(&T) -> R, 
[src]

pub fn with_or<F, I, R>(&self, f: F, init: I) -> R where
    F: FnOnce(&T) -> R,
    I: FnOnce() -> T, 
[src]

pub fn with_try_or<F, I, R, E>(&self, f: F, init: I) -> Result<R, E> where
    F: FnOnce(&T) -> R,
    I: 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>[src]

impl<T> Unpin for ThreadLocal<T>[src]

impl<T> UnwindSafe for ThreadLocal<T> where
    T: UnwindSafe
[src]

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.