2 #ifndef _YI_LAZY_IMPL_H 3 #define _YI_LAZY_IMPL_H 5 #if !defined(_YI_LAZY_H_) 6 #error "Do not include YiLazy_impl.h directly. Please include YiLazy.h instead." 11 template<
class YI_CLASS>
17 template<
class YI_CLASS>
20 YI_CLASS *pInstance = m_pInstance.load();
24 m_pInstance.store(
nullptr);
28 template<
class YI_CLASS>
31 YI_CLASS *pInstance = m_pInstance.load();
32 if (pInstance ==
nullptr)
34 pInstance =
new YI_CLASS();
35 YI_CLASS *pNullInstance =
nullptr;
36 if (!m_pInstance.compare_exchange_strong(pNullInstance, pInstance))
39 pInstance = m_pInstance.load();
45 template<
class YI_CLASS>
51 template<
class YI_CLASS>
54 return m_pInstance.load();
57 template<
class YI_CLASS>
60 return m_pInstance.load();
~CYILazy()
Definition: YiLazy_impl.h:18
CYILazy is a thread-safe lazy initializer of a class. The instance pointer remains null until CYILazy...
Definition: YiLazy.h:48
CYILazy()
Definition: YiLazy_impl.h:12
const YI_CLASS * Get() const
Definition: YiLazy_impl.h:29
const YI_CLASS * TryGet() const
Definition: YiLazy_impl.h:52