[−][src]Struct per_thread_object::ThreadLocal
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 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>,
Trait Implementations
impl<T: Send + 'static> Default for ThreadLocal<T>
[src]
fn default() -> 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]
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, 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>,