You.i Engine
YiLazy.h
Go to the documentation of this file.
1 // © You i Labs Inc. 2000-2017. All rights reserved.
2 #ifndef _YI_LAZY_H_
3 #define _YI_LAZY_H_
4 
5 #include "framework/YiPredef.h"
6 
7 #include <atomic>
8 
47 template <class YI_CLASS>
48 class CYILazy
49 {
50 public:
54  CYILazy();
55 
59  ~CYILazy();
60 
70  const YI_CLASS *Get() const;
71 
75  YI_CLASS *Get();
76 
81  const YI_CLASS *TryGet() const;
85  YI_CLASS *TryGet();
86 
87 private:
88  CYILazy(const CYILazy &) = delete;
89  CYILazy &operator=(const CYILazy &) = delete;
90 
91  mutable std::atomic<YI_CLASS *> m_pInstance;
92 };
93 
96 #include "utility/YiLazy_impl.h"
97 
98 #endif /* _YI_LAZY_H_ */
~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