[#BloombergLP-bsls-BslOnce]
= xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/bsls.adoc[bsls]::BslOnce
:relfileprefix: ../../
:mrdocs:

Gate&hyphen;keeper that ensures a block of code is executed only once&period;

== Synopsis

Declared in `&lt;bsls&lowbar;bslonce&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
struct BslOnce;
----

== Description

This `struct` provides a simple data type for ensuring a block of code is executed (only) once&period; Note that this is defined as a `struct` to allow constant initialization in a global or static context using `BSLS&lowbar;BSLONCE&lowbar;INITIALIZER`&period;

== Member Functions

[cols="1,4"]
|===
| Name| Description
| xref:BloombergLP/bsls/BslOnce/enter.adoc[`enter`] 
| Enter the one&hyphen;time block of code&period;
| xref:BloombergLP/bsls/BslOnce/leave.adoc[`leave`] 
| Exit the one&hyphen;time block of code&period; The behavior is undefined unless the caller had previously called `enter`, and `enter` had returned `true`&period;
|===


== Data Members

[cols="1,4"]
|===
| Name| Description
| xref:BloombergLP/bsls/BslOnce/d_onceState.adoc[`d&lowbar;onceState`] 
| State of the one&hyphen;time block of code managed by this object&period;
|===



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