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