Mobile API Reference
MicroStrategy 2019
ReferenceCountedImplementation.h
Go to the documentation of this file.
1
//==============================================================================================
2
// FILENAME : ReferenceCountedImplementation.h
3
// AUTHOR : Juan Pablo Muraira
4
// CREATION : 9/26/01
5
// Copyright (C) MicroStrategy Incorporated 2001
6
//==============================================================================================
7
#ifndef MSynch_ReferenceCountedImplementation_h
8
#define MSynch_ReferenceCountedImplementation_h
9
10
#include "
Base/Defines/Asserte.h
"
11
#include "
Synch/Synch/AtomicLong.h
"
12
13
#define REFERENCE_COUNTED_INITIALIZATION mnReferenceCount(0)
14
15
/*
16
* Derive your class from MBase::ReferenceCounted to get the standard interface
17
* of reference counting. You may get the reference counted implementation
18
* by inserting the REFERENCE_COUNTED_IMPLEMENTATION macro on your implementation
19
* class.
20
*/
21
#define REFERENCE_COUNTED_IMPLEMENTATION \
22
public: \
23
virtual void AddRef() const throw() \
24
{ \
25
++mnReferenceCount; \
26
} \
27
virtual void Release() const throw() \
28
{ \
29
/* Reference count is corrupted */
\
30
_ASSERTE(mnReferenceCount>0); \
31
if ((--mnReferenceCount) == 0) \
32
{ \
33
/* That was the last reference */
\
34
delete this; \
35
} \
36
} \
37
private: \
38
mutable MSynch::AtomicLong mnReferenceCount;
39
40
#endif // MSynch_ReferenceCountedImplementation_h
Asserte.h
AtomicLong.h
Users
vvitarello
Desktop
MobileSDKSourceFiles
Synch
Defines
ReferenceCountedImplementation.h
Generated by
1.8.14