[#BloombergLP-bslmt-Once-callOnce-0f] = xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/bslmt.adoc[bslmt]::xref:BloombergLP/bslmt/Once.adoc[Once]::callOnce :relfileprefix: ../../../ :mrdocs: Call `function` at most once across all threads for this object. == Synopsis Declared in `<bslmt_once.h>` [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- template<class FUNC> void callOnce(FUNC& function); ---- == Description 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. Otherwise, wait for the one‐time code to complete and return without calling `function` where `function` is a function or functor that can be called with no arguments. Note that one‐time code is considered not to have run if `function` terminates with an exception. == Parameters [cols="1,4"] |=== | Name| Description | *function* | no‐argument function or functor to invoke at most once |=== [.small]#Created with https://www.mrdocs.com[MrDocs]#