pub(crate) struct OnceCell<T> {
queue: AtomicPtr<Waiter>,
value: UnsafeCell<Option<T>>,
}
Fields§
§queue: AtomicPtr<Waiter>
§value: UnsafeCell<Option<T>>
Implementations§
source§impl<T> OnceCell<T>
impl<T> OnceCell<T>
pub(crate) const fn new() -> OnceCell<T>
pub(crate) const fn with_value(value: T) -> OnceCell<T>
sourcepub(crate) fn is_initialized(&self) -> bool
pub(crate) fn is_initialized(&self) -> bool
Safety: synchronizes with store to value via Release/(Acquire|SeqCst).
sourcepub(crate) fn initialize<F, E>(&self, f: F) -> Result<(), E>
pub(crate) fn initialize<F, E>(&self, f: F) -> Result<(), E>
Safety: synchronizes with store to value via SeqCst read from state, writes value only once because we never get to INCOMPLETE state after a successful write.
pub(crate) fn wait(&self)
sourcepub(crate) unsafe fn get_unchecked(&self) -> &T
pub(crate) unsafe fn get_unchecked(&self) -> &T
Get the reference to the underlying value, without checking if the cell is initialized.
§Safety
Caller must ensure that the cell is in initialized state, and that the contents are acquired by (synchronized to) this thread.
sourcepub(crate) fn get_mut(&mut self) -> Option<&mut T>
pub(crate) fn get_mut(&mut self) -> Option<&mut T>
Gets the mutable reference to the underlying value.
Returns None
if the cell is empty.
sourcepub(crate) fn into_inner(self) -> Option<T>
pub(crate) fn into_inner(self) -> Option<T>
Consumes this OnceCell
, returning the wrapped value.
Returns None
if the cell was empty.
Trait Implementations§
impl<T: RefUnwindSafe + UnwindSafe> RefUnwindSafe for OnceCell<T>
impl<T: Send> Send for OnceCell<T>
impl<T: Sync + Send> Sync for OnceCell<T>
impl<T: UnwindSafe> UnwindSafe for OnceCell<T>
Auto Trait Implementations§
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