[#BloombergLP-bslmt-Once] = xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/bslmt.adoc[bslmt]::Once :relfileprefix: ../../ :mrdocs: Gate‐keeper class for code that should only execute once per process. == Synopsis Declared in `<bslmt_once.h>` [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- class Once; ---- == Description This class is a POD‐type and can be statically initialized to the value of the `BSLMT_ONCE_INITIALIZE` macro. For this reason, it does not have any explicitly‐declared constructors or destructor. == Type Aliases [cols="1,4"] |=== | Name| Description | xref:BloombergLP/bslmt/Once/OnceLock.adoc[`OnceLock`] | Special token created by a single thread to pass to the `enter`, `leave`, and `cancel` methods. |=== == Member Functions [cols="1,4"] |=== | Name| Description | xref:BloombergLP/bslmt/Once/callOnce-02.adoc[`callOnce`] | Call `function` at most once across all threads for this object. | xref:BloombergLP/bslmt/Once/cancel.adoc[`cancel`] | Abort incomplete one‐time execution and unlock the internal mutex. | xref:BloombergLP/bslmt/Once/enter.adoc[`enter`] | Attempt to enter the one‐time execution region for this object. | xref:BloombergLP/bslmt/Once/isMaybeUninitialized.adoc[`isMaybeUninitialized`] | Return `true` if this object may not be in the "done" state (that is, `leave` has not been called). | xref:BloombergLP/bslmt/Once/leave.adoc[`leave`] | Mark one‐time execution as complete and unlock the internal mutex. |=== == Data Members [cols="1,4"] |=== | Name| Description | xref:BloombergLP/bslmt/Once/d_mutex.adoc[`d_mutex`] | Mutex used to synchronize one‐time execution. Public for static initialization, but do _not_ access directly. | xref:BloombergLP/bslmt/Once/d_state.adoc[`d_state`] | One‐time execution state. Public for static initialization, but do _not_ access directly. |=== [.small]#Created with https://www.mrdocs.com[MrDocs]#