Attempt to enter the one‐time block managed by once.

Synopsis

Declared in <bsls_bslonce.h>

bool
enter(BslOnce* once);

Description

Enter the one‐time block of code that is managed by the specified once. Return true if the one‐time block of code has been entered, and false if the one‐time block of code has already been executed. If this function returns false then the thread of execution in which enter returned true has already called leave ‐‐ i.e., the one‐time block of code is guaranteed to have completed execution. The behavior is undefined unless once was originally initialized to BSLS_BSLONCE_INITIALIZER. Note that a successful enter locks a spin‐lock; it is imperative that leave be called quickly.

Return Value

true if this call entered the block, else false

Parameters

Name

Description

once

once‐control object managing the one‐time block

Created with MrDocs