pub struct DroppingThreadLocal<T: Send + Sync + 'static> { /* private fields */ }
Expand description
A thread local that drops its value when the thread is destroyed.
See module-level documentation for more details.
Dropping this value will free all the associated values.
Implementations§
Source§impl<T: Send + Sync + 'static> DroppingThreadLocal<T>
impl<T: Send + Sync + 'static> DroppingThreadLocal<T>
Sourcepub fn get(&self) -> Option<SharedRef<T>>
pub fn get(&self) -> Option<SharedRef<T>>
Get the value associated with the current thread,
or None
if not initialized.
Sourcepub fn get_or_init(&self, func: impl FnOnce() -> T) -> SharedRef<T>
pub fn get_or_init(&self, func: impl FnOnce() -> T) -> SharedRef<T>
Get the value associated with the current thread, initializing it if not yet defined.
Sourcepub fn snapshot_iter(&self) -> SnapshotIter<T> ⓘ
pub fn snapshot_iter(&self) -> SnapshotIter<T> ⓘ
Iterate over currently live values and their associated thread ids.
New threads that have been spanned after the snapshot was taken will not be present in the iterator. Threads that die after the snapshot is taken may or may not be present. Values from threads that die before the snapshot will not be present.
The order of the iteration is undefined.
Trait Implementations§
Auto Trait Implementations§
impl<T> Freeze for DroppingThreadLocal<T>
impl<T> RefUnwindSafe for DroppingThreadLocal<T>where
T: RefUnwindSafe,
impl<T> Send for DroppingThreadLocal<T>
impl<T> Sync for DroppingThreadLocal<T>
impl<T> Unpin for DroppingThreadLocal<T>
impl<T> UnwindSafe for DroppingThreadLocal<T>where
T: RefUnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more