7 #ifndef __FWCORE_UTIL_LAZYINSTANTIATOR_HPP__ 8 #define __FWCORE_UTIL_LAZYINSTANTIATOR_HPP__ 10 #include <boost/thread/once.hpp> 11 #include <boost/noncopyable.hpp> 27 template<
typename INSTANCE_TYPE,
typename TAG = LazyInstantiatorDefaultTag >
32 typedef INSTANCE_TYPE InstanceType;
34 typedef std::shared_ptr<InstanceType> InstanceSptrType;
39 static ::boost::once_flag flag = BOOST_ONCE_INIT;
40 ::boost::call_once(&initInstance, flag);
55 static InstanceSptrType s_instance;
58 s_instance = std::make_shared< InstanceType >();
static InstanceSptrType getInstance()
Returns the singleton instance. This method is thread safe.
This file defines fwCore base macros.
This namespace fwCore provides common foundations for FW4SPL.
static InstanceSptrType instance()
Initializes once and returns the instance (not thread-safe)
static void initInstance()
Initializes the singleton instance.
A base class for lazy instantiation, constructed on first demand.