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

If no other thread has yet called `enter` or `callOnce`, then call the specified `function` and set this object to the state where pending and future calls to `enter` or `callOnce` will return `false` or do nothing, respectively&period; Otherwise, wait for the one&hyphen;time code to complete and return without calling `function` where `function` is a function or functor that can be called with no arguments&period; Note that one&hyphen;time code is considered not to have run if `function` terminates with an exception&period;

== Synopses

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

If no other thread has yet called `enter` or `callOnce`, then call the specified `function` and set this object to the state where pending and future calls to `enter` or `callOnce` will return `false` or do nothing, respectively&period; Otherwise, wait for the one&hyphen;time code to complete and return without calling `function` where `function` is a function or functor that can be called with no arguments&period; Note that one&hyphen;time code is considered not to have run if `function` terminates with an exception&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;class FUNC&gt;
void
xref:BloombergLP/bslmt/Once/callOnce-0f.adoc[callOnce](FUNC& function);
----

[.small]#xref:BloombergLP/bslmt/Once/callOnce-0f.adoc[_» more&period;&period;&period;_]#

If no other thread has yet called `enter` or `callOnce`, then call the specified `function` and set this object to the state where pending and future calls to `enter` or `callOnce` will return `false` or do nothing, respectively&period; Otherwise, wait for the one&hyphen;time code to complete and return without calling `function` where `function` is a function or functor that can be called with no arguments&period; Note that one&hyphen;time code is considered not to have run if `function` terminates with an exception&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;class FUNC&gt;
void
xref:BloombergLP/bslmt/Once/callOnce-03.adoc[callOnce](FUNC const& function);
----

[.small]#xref:BloombergLP/bslmt/Once/callOnce-03.adoc[_» more&period;&period;&period;_]#


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