BDE 4.14.0 Production release
|
#include <bslmt_once.h>
Public Member Functions | |
OnceGuard (Once *once=0) | |
~OnceGuard () | |
void | setOnce (Once *once) |
bool | enter () |
void | leave () |
void | cancel () |
bool | isInProgress () const |
Guard class for using Once
safely. 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.
See bslmt_once
|
inlineexplicit |
Initialize this object to guard the (optionally) specified once
object. If once
is not specified, then it must be set later using the setOnce
method before other methods may be called.
bslmt::OnceGuard::~OnceGuard | ( | ) |
Destroy this object. If this object is not in an "in-progress" state, do nothing. If this object is in an "in-progress" state and is being destroyed in the course of normal processing, then call leave
on the associated Once
object.
void bslmt::OnceGuard::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.
bool bslmt::OnceGuard::enter | ( | ) |
Call enter
on the associated Once
object and return the result. If Once::enter
returns true
, set this object into the "in-progress" state. The behavior is undefined unless this object has been associated with a Once
object, either in the constructor or using setOnce
, or if this object is already in the "in-progress" state.
|
inline |
Return true
if this object is in the "in-progress" state. The object is in-progress if enter
has been called and returned true
and neither leave
nor cancel
have been called. The one-time code controlled by this object should only be executing if this object is in the "in-progress" state.
void bslmt::OnceGuard::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.
|
inline |
Set this object to guard the specified once
object. The behavior is undefined if this object is currently in the "in-progress" state.