pub struct OnceLite(/* private fields */);Expand description
A lightweight call_once primitive.
This structure provides the Rust equivalent of the kernel’s DO_ONCE_LITE macro.
While it would be possible to implement the feature entirely as a Rust macro,
the functionality that can be implemented as regular functions has been
extracted and implemented as the OnceLite struct for better code maintainability.
Implementations§
Source§impl OnceLite
impl OnceLite
Sourcepub fn call_once<F>(&self, f: F) -> boolwhere
F: FnOnce(),
pub fn call_once<F>(&self, f: F) -> boolwhere
F: FnOnce(),
Calls the provided function exactly once.
There is no other synchronization between two call_once()s
except that only one will execute f, in other words, callers
should not use a failed call_once() as a proof that another
call_once() has already finished and the effect is observable
to this thread.
Auto Trait Implementations§
impl !Freeze for OnceLite
impl !RefUnwindSafe for OnceLite
impl Send for OnceLite
impl Sync for OnceLite
impl Unpin for OnceLite
impl UnwindSafe for OnceLite
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
Source§impl<T> PinInit<T> for T
impl<T> PinInit<T> for T
Source§unsafe fn __pinned_init(self, slot: *mut T) -> Result<(), Infallible>
unsafe fn __pinned_init(self, slot: *mut T) -> Result<(), Infallible>
Initializes
slot. Read more