8#ifndef INCLUDED_BSLMT_ONCE
9#define INCLUDED_BSLMT_ONCE
386#include <bslscm_version.h>
396#include <bsl_exception.h>
400#if defined(BSLS_PLATFORM_CMP_MSVC)
401# define BSLMT_ONCE_UNIQNUM __COUNTER__
406# define BSLMT_ONCE_UNIQNUM __LINE__
425#define BSLMT_ONCE_DO \
426 BSLMT_ONCE_DO_IMP(BSLMT_ONCE_CAT(bslmt_doOnceObj, BSLMT_ONCE_UNIQNUM))
435#define BSLMT_ONCE_CANCEL() bslmt_doOnceGuard.cancel()
437#define BSLMT_ONCE_INITIALIZER { BSLMT_QLOCK_INITIALIZER, { 0 } }
459 enum { e_NOT_ENTERED, e_IN_PROGRESS, e_DONE };
475 bsls::AtomicOperations::AtomicTypes::Int
d_state;
525 template <
class FUNC>
527 template <
class FUNC>
528 void callOnce(
const FUNC& function);
551 enum State { e_NOT_ENTERED, e_IN_PROGRESS, e_DONE };
557 int d_num_exceptions;
621#define BSLMT_ONCE_CAT(X, Y) BSLMT_ONCE_CAT_IMP(X, Y)
622#define BSLMT_ONCE_CAT_IMP(X, Y) X##Y
631#define BSLMT_ONCE_DO_IMP(doOnceObj) \
632 static BloombergLP::bslmt::Once doOnceObj = BSLMT_ONCE_INITIALIZER; \
633 if (BSLS_PERFORMANCEHINT_PREDICT_UNLIKELY( \
634 doOnceObj.isMaybeUninitialized())) \
635 for (BloombergLP::bslmt::OnceGuard \
636 bslmt_doOnceGuard(&doOnceObj);\
637 bslmt_doOnceGuard.enter(); bslmt_doOnceGuard.leave())
645OnceGuard::OnceGuard(
Once *once)
647, d_state(e_NOT_ENTERED)
648, d_num_exceptions(
bsl::uncaught_exceptions())
659 d_state = e_NOT_ENTERED;
666 return e_IN_PROGRESS == d_state;
680#ifdef BDE_BUILD_TARGET_EXC
700#ifdef BDE_BUILD_TARGET_EXC
724#if !defined(BSL_DOUBLE_UNDERSCORE_XLAT) || 1 == BSL_DOUBLE_UNDERSCORE_XLAT
725#define BSLMT_ONCE__CAT(X, Y) BSLMT_ONCE_CAT(X, Y)
Definition bslmt_once.h:548
bool isInProgress() const
Definition bslmt_once.h:664
void setOnce(Once *once)
Definition bslmt_once.h:654
Definition bslmt_once.h:456
QLock d_mutex
Definition bslmt_once.h:473
bool enter(OnceLock *onceLock)
bool isMaybeUninitialized() const
Definition bslmt_once.h:716
void leave(OnceLock *onceLock)
void callOnce(FUNC &function)
Definition bslmt_once.h:676
bsls::AtomicOperations::AtomicTypes::Int d_state
Definition bslmt_once.h:475
void cancel(OnceLock *onceLock)
QLockGuard OnceLock
Definition bslmt_once.h:483
Definition bslmt_qlock.h:381
#define BSLS_ASSERT_SAFE(X)
Definition bsls_assert.h:1762
#define BSLS_IDENT(str)
Definition bsls_ident.h:195
Definition bdlb_printmethods.h:283
Definition bslmt_barrier.h:344
Definition bslmt_qlock.h:271
static int getIntAcquire(AtomicTypes::Int const *atomicInt)
Definition bsls_atomicoperations.h:1528