Attempt to enter the one‐time execution region for this object.

Synopsis

Declared in <bslmt_once.h>

bool
enter(OnceLock* onceLock);

Description

Lock the internal mutex using the specified onceLock (possibly blocking if another thread has already locked the mutex). If no other thread has yet called enter or callOnce on this object, return true. Otherwise, unlock the mutex and return false. The mutex lock may be skipped if it can be determined that it will not be needed. The behavior is undefined if onceLock is already in a locked state on entry to this method. Note that if enter returns true, the caller must eventually call leave, or else other threads may block indefinitely.

Return Value

true if this thread entered the one‐time region, and false otherwise

Parameters

Name

Description

onceLock

lock token used to hold the internal mutex

Created with MrDocs