Struct linux_once::Once [−][src]
A synchronization primitive which can be used to run a one-time global initialization. Useful
for one-time initialization for FFI or related functionality. This type can only be constructed
with Once::new()
.
Implementations
impl Once
[src]
pub const fn new() -> Self
[src]
Creates a new Once
value.
pub fn call_once<F: FnOnce()>(&self, f: F)
[src]
Performs an initialization routine once and only once. The given closure will be executed if
this is the first time call_once
has been called, and otherwise the routine will not be
invoked.
This method will block the calling thread if another initialization routine is currently running.
When this function returns, it is guaranteed that some initialization has run and completed (it may not be the closure specified). It is also guaranteed that any memory writes performed by the executed closure can be reliably observed by other threads at this point (there is a happens-before relation between the closure and code executing after the return).
If the given closure recursively invokes call_once on the same Once
instance the exact
behavior is not specified, allowed outcomes are a panic or a deadlock.
Note specific to the Linux version: recursive calls currently cause deadlock. This information is only intended to help debugging and must not be relied on.
pub fn is_completed(&self) -> bool
[src]
Returns true
if some call_once()
call has completed successfully. Specifically, is_completed
will return false in the following situations:
call_once()
was not called at all,call_once()
was called, but has not yet completed,- the
Once
instance is poisoned
This function returning false
does not mean that Once
has not been executed. For example, it
may have been executed in the time between when is_completed
starts executing and when it returns,
in which case the false
return value would be stale (but still permissible).
Auto Trait Implementations
impl RefUnwindSafe for Once
[src]
impl Send for Once
[src]
impl Sync for Once
[src]
impl Unpin for Once
[src]
impl UnwindSafe for Once
[src]
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>,