Struct sgx_tstd::sync::Once[][src]

pub struct Once { /* fields omitted */ }

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 the ONCE_INIT value.

Methods

impl Once
[src]

Creates a new Once value.

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).

Panics

The closure f will only be executed once if this is called concurrently amongst many threads. If that closure panics, however, then it will poison this Once instance, causing all future invocations of call_once to also panic.

This is similar to poisoning with mutexes.

Performs the same function as call_once except ignores poisoning.

If this Once has been poisoned (some initialization panicked) then this function will continue to attempt to call initialization functions until one of them doesn't panic.

The closure f is yielded a OnceState structure which can be used to query the state of this Once (whether initialization has previously panicked or not).

Trait Implementations

impl Sync for Once
[src]

impl Send for Once
[src]

impl Debug for Once
[src]

Formats the value using the given formatter. Read more