Struct crossbeam_epoch::sync::once_lock::OnceLock
source · pub(crate) struct OnceLock<T> {
once: Once,
value: UnsafeCell<MaybeUninit<T>>,
}
Fields§
§once: Once
§value: UnsafeCell<MaybeUninit<T>>
Implementations§
source§impl<T> OnceLock<T>
impl<T> OnceLock<T>
sourcepub(crate) fn get_or_init<F>(&self, f: F) -> &Twhere
F: FnOnce() -> T,
pub(crate) fn get_or_init<F>(&self, f: F) -> &Twhere
F: FnOnce() -> T,
Gets the contents of the cell, initializing it with f
if the cell
was empty.
Many threads may call get_or_init
concurrently with different
initializing functions, but it is guaranteed that only one function
will be executed.
§Panics
If f
panics, the panic is propagated to the caller, and the cell
remains uninitialized.
It is an error to reentrantly initialize the cell from f
. The
exact outcome is unspecified. Current implementation deadlocks, but
this may be changed to a panic in the future.
fn initialize<F>(&self, f: F)where
F: FnOnce() -> T,
sourceunsafe fn get_unchecked(&self) -> &T
unsafe fn get_unchecked(&self) -> &T
§Safety
The value must be initialized
Trait Implementations§
impl<T: Send> Send for OnceLock<T>
impl<T: Sync + Send> Sync for OnceLock<T>
Auto Trait Implementations§
impl<T> !Freeze for OnceLock<T>
impl<T> !RefUnwindSafe for OnceLock<T>
impl<T> Unpin for OnceLock<T>where
T: Unpin,
impl<T> UnwindSafe for OnceLock<T>where
T: UnwindSafe,
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