Revert "Minor modernization of DynamicAny code"
[ACE_TAO.git] / TAO / tao / Intrusive_Ref_Count_Base_T.h
blob0bd741981cb692038639696963d63c624db21762
1 // -*- C++ -*-
3 //=============================================================================
4 /**
5 * @file Intrusive_Ref_Count_Base_T.h
7 * @authors Tim Bradley <bradley_t@ociweb.com>
8 */
9 //=============================================================================
11 #ifndef TAO_INTRUSIVE_REF_COUNT_BASE_T_H
12 #define TAO_INTRUSIVE_REF_COUNT_BASE_T_H
14 #include /**/ "ace/pre.h"
16 #if !defined (ACE_LACKS_PRAGMA_ONCE)
17 # pragma once
18 #endif /* ACE_LACKS_PRAGMA_ONCE */
20 #include /**/ "tao/Versioned_Namespace.h"
22 #include "tao/Basic_Types.h"
23 #include <atomic>
25 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
27 /**
28 * @class TAO_Intrusive_Ref_Count_Base<ACE_LOCK>
30 * @brief Template base class to provide intrusive reference-counting
31 * to subclasses. This makes the subclass capable of using a
32 * TAO_Intrusive_Ref_Count_Handle<X> class as a smart-pointer
33 * to an X object. In this case, X is a sub-class of this class,
34 * TAO_Intrusive_Ref_Count_Base<ACE_LOCK>. The ACE_LOCK type is
35 * used to protect the atomic reference count data member.
37 template <class ACE_LOCK>
38 class TAO_Intrusive_Ref_Count_Base
40 public:
41 virtual ~TAO_Intrusive_Ref_Count_Base ();
43 void _add_ref ();
44 void _remove_ref ();
46 protected:
47 TAO_Intrusive_Ref_Count_Base ();
49 private:
50 std::atomic<uint32_t> refcount_;
52 // Prevent copying/assignment.
53 TAO_Intrusive_Ref_Count_Base (const TAO_Intrusive_Ref_Count_Base&);
54 TAO_Intrusive_Ref_Count_Base& operator= (const TAO_Intrusive_Ref_Count_Base&);
57 TAO_END_VERSIONED_NAMESPACE_DECL
59 #if defined (__ACE_INLINE__)
60 #include "tao/Intrusive_Ref_Count_Base_T.inl"
61 #endif /* __ACE_INLINE__ */
63 #include "tao/Intrusive_Ref_Count_Base_T.cpp"
65 #include /**/ "ace/post.h"
67 #endif /* TAO_INTRUSIVE_REF_COUNT_BASE_T_H */