You.i Engine
YiReferenceCounter.h
Go to the documentation of this file.
1 // © You i Labs Inc. 2000-2017. All rights reserved.
2 #ifndef _YI_REFERENCE_COUNTER_H_
3 #define _YI_REFERENCE_COUNTER_H_
4 
5 #include "framework/YiPredef.h"
7 
8 #include <atomic>
9 
10 #define YI_LOG_SHARED_PTR_COUNTS 0
11 
24 {
25 public:
34  inline CYIReferenceCounter();
35 
39  inline ~CYIReferenceCounter();
40 
46  inline uint32_t StrongRef();
47 
53  inline uint32_t StrongDeref();
54 
60  inline uint32_t WeakRef();
61 
67  inline uint32_t WeakDeref();
68 
73  inline uint32_t GetStrongRefCount() const;
74 
79  inline uint32_t GetWeakRefCount() const;
80 
81 #if YI_LOG_SHARED_PTR_COUNTS
82 
85  inline void EnableCountsLogging();
86 
90  inline bool IsCountsLoggingEnabled() const;
91 #endif
92 
93 private:
94 
96  CYIReferenceCounter& operator=(const CYIReferenceCounter &rOther);
97 
98 #if YI_LOG_SHARED_PTR_COUNTS
99  bool m_bLogCounts;
100 #endif
101  std::atomic<uint32_t> m_uStrongRefCount;
102  std::atomic<uint32_t> m_uWeakRefCount;
103 };
104 
107 #include "smartptr/YiReferenceCounter.inl"
108 
109 #endif /* _YI_REFERENCE_COUNTER_H_ */
Definition: YiReferenceCounter.h:23
uint32_t GetWeakRefCount() const
uint32_t WeakDeref()
uint32_t StrongRef()
uint32_t StrongDeref()
uint32_t GetStrongRefCount() const