[−][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 with<F, R>(&self, f: F) -> R where
F: FnOnce(&T) -> R,
[src]
F: FnOnce(&T) -> R,
pub fn try_with<F, R>(&self, f: F) -> Option<R> where
F: FnOnce(&T) -> R,
[src]
F: FnOnce(&T) -> R,
pub fn with_or<F, I, R>(&self, f: F, init: I) -> R where
F: FnOnce(&T) -> R,
I: FnOnce() -> T,
[src]
F: FnOnce(&T) -> R,
I: FnOnce() -> T,
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]
F: FnOnce(&T) -> R,
I: FnOnce() -> Result<T, E>,
Trait Implementations
impl<T: Send + 'static> Default for ThreadLocal<T>
[src]
pub 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>
[src]
impl<T> Unpin for ThreadLocal<T>
[src]
impl<T> UnwindSafe for ThreadLocal<T> where
T: UnwindSafe,
[src]
T: UnwindSafe,
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,
pub 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.
pub 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>,