[#BloombergLP-bsls-BslOnce] = xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/bsls.adoc[bsls]::BslOnce :relfileprefix: ../../ :mrdocs: Gate‐keeper that ensures a block of code is executed only once. == Synopsis Declared in `<bsls_bslonce.h>` [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. Note that this is defined as a `struct` to allow constant initialization in a global or static context using `BSLS_BSLONCE_INITIALIZER`. == Member Functions [cols="1,4"] |=== | Name| Description | xref:BloombergLP/bsls/BslOnce/enter.adoc[`enter`] | Enter the one‐time block of code. | xref:BloombergLP/bsls/BslOnce/leave.adoc[`leave`] | Exit the one‐time block of code. The behavior is undefined unless the caller had previously called `enter`, and `enter` had returned `true`. |=== == Data Members [cols="1,4"] |=== | Name| Description | xref:BloombergLP/bsls/BslOnce/d_onceState.adoc[`d_onceState`] | State of the one‐time block of code managed by this object. |=== [.small]#Created with https://www.mrdocs.com[MrDocs]#