[#BloombergLP-bslmt-Once]
= xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/bslmt.adoc[bslmt]::Once
:relfileprefix: ../../
:mrdocs:

Gate&hyphen;keeper class for code that should only execute once per process&period;

== Synopsis

Declared in `&lt;bslmt&lowbar;once&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
class Once;
----

== Description

This class is a POD&hyphen;type and can be statically initialized to the value of the `BSLMT&lowbar;ONCE&lowbar;INITIALIZE` macro&period; For this reason, it does not have any explicitly&hyphen;declared constructors or destructor&period;

== 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&period;
|===


== 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&period;
| xref:BloombergLP/bslmt/Once/cancel.adoc[`cancel`] 
| Abort incomplete one&hyphen;time execution and unlock the internal mutex&period;
| xref:BloombergLP/bslmt/Once/enter.adoc[`enter`] 
| Attempt to enter the one&hyphen;time execution region for this object&period;
| xref:BloombergLP/bslmt/Once/isMaybeUninitialized.adoc[`isMaybeUninitialized`] 
| Return `true` if this object may not be in the &quot;done&quot; state (that is, `leave` has not been called)&period;
| xref:BloombergLP/bslmt/Once/leave.adoc[`leave`] 
| Mark one&hyphen;time execution as complete and unlock the internal mutex&period;
|===


== Data Members

[cols="1,4"]
|===
| Name| Description
| xref:BloombergLP/bslmt/Once/d_mutex.adoc[`d&lowbar;mutex`] 
| Mutex used to synchronize one&hyphen;time execution&period; Public for static initialization, but do _not_ access directly&period;
| xref:BloombergLP/bslmt/Once/d_state.adoc[`d&lowbar;state`] 
| One&hyphen;time execution state&period; Public for static initialization, but do _not_ access directly&period;
|===



[.small]#Created with https://www.mrdocs.com[MrDocs]#
