20#ifndef INCLUDED_COMPHELPER_DOUBLECHECKEDINIT_HXX
21#define INCLUDED_COMPHELPER_DOUBLECHECKEDINIT_HXX
23#include <osl/getglobalmutex.hxx>
41template <
typename Type,
typename Function = std::function<Type*()>,
42 typename Guard = osl::MutexGuard,
typename GuardCtor = osl::GetGlobalMutex>
44 GuardCtor guardCtor = osl::GetGlobalMutex())
46 Type*
p = pointer.load(std::memory_order_acquire);
49 Guard guard(guardCtor());
50 p = pointer.load(std::memory_order_relaxed);
54 pointer.store(
p, std::memory_order_release);
static Type * doubleCheckedInit(std::atomic< Type * > &pointer, Function function, GuardCtor guardCtor=osl::GetGlobalMutex())
Thread-safe singleton creation.