BloombergLP::bslmt::OnceGuard

Guard class for using Once safely.

Synopsis

Declared in <bslmt_once.h>

class OnceGuard;

Description

Construct an object of this class before conditionally entering one-time processing code. Destroy the object when the one-time code is complete. When used this way, this object will be in an "in-progress" state during the time that the one-time code is being executed.

Member Functions

NameDescription
OnceGuard [constructor]Create a guard optionally associated with the specified once object.
~OnceGuard [destructor]Destroy this object, completing in-progress once work if needed.
cancel If this object is in the "in-progress" state, call cancel on the associated Once object and exit the "in-progress" state. Otherwise, do nothing.
enter Enter the associated Once object's one-time region if allowed.
isInProgress Return true if this object is in the "in-progress" state.
leave If this object is in the "in-progress" state, call leave on the associated Once object and exit the "in-progress" state. Otherwise, do nothing.
setOnce Set this object to guard the specified once object. The behavior is undefined if this object is currently in the "in-progress" state.