diff options
author | dai_y <dai_y@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2005-10-19 00:27:51 +0000 |
---|---|---|
committer | dai_y <dai_y@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2005-10-19 00:27:51 +0000 |
commit | b29e5800752ecefbe4e9317ac908e40d9c6eded0 (patch) | |
tree | 3bdec835860a692ca76bdcd5baa5f069645bf248 /TAO/tao/Intrusive_Ref_Count_Base_T.h | |
parent | 189f1baf20ea719b1724adef186b8699706eb065 (diff) | |
download | ATCD-b29e5800752ecefbe4e9317ac908e40d9c6eded0.tar.gz |
Tue Oct 18 17:24:26 MST 2005 Yan Dai <dai_y@ociweb.com>
Diffstat (limited to 'TAO/tao/Intrusive_Ref_Count_Base_T.h')
-rw-r--r-- | TAO/tao/Intrusive_Ref_Count_Base_T.h | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/TAO/tao/Intrusive_Ref_Count_Base_T.h b/TAO/tao/Intrusive_Ref_Count_Base_T.h new file mode 100644 index 00000000000..f37041bd02c --- /dev/null +++ b/TAO/tao/Intrusive_Ref_Count_Base_T.h @@ -0,0 +1,75 @@ +// This may look like C, but it's really -*- C++ -*- + +//============================================================================= +/** + * @file Intrusive_Ref_Count_Base_T.h + * + * $Id$ + * + * @authors Tim Bradley <bradley_t@ociweb.com> + */ +//============================================================================= + +#ifndef TAO_INTRUSIVE_REF_COUNT_BASE_T_H +#define TAO_INTRUSIVE_REF_COUNT_BASE_T_H + +#include /**/ "ace/pre.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/Atomic_Op.h" + + +/** + * @class TAO_Intrusive_Ref_Count_Base<ACE_LOCK> + * + * @brief Template base class to provide intrusive reference-counting + * to subclasses. This makes the subclass capable of using a + * TAO_Intrusive_Ref_Count_Handle<X> class as a smart-pointer + * to an X object. In this case, X is a sub-class of this class, + * TAO_Intrusive_Ref_Count_Base<ACE_LOCK>. The ACE_LOCK type is + * used to protect the atomic reference count data member. + * + */ +template <class ACE_LOCK> +class TAO_Intrusive_Ref_Count_Base +{ +public: + + virtual ~TAO_Intrusive_Ref_Count_Base(); + + void _add_ref(); + void _remove_ref(); + + +protected: + + TAO_Intrusive_Ref_Count_Base(); + + +private: + + ACE_Atomic_Op<ACE_LOCK, long> ref_count_; + + // Not implemented. + TAO_Intrusive_Ref_Count_Base(const TAO_Intrusive_Ref_Count_Base&); + TAO_Intrusive_Ref_Count_Base& operator=(const TAO_Intrusive_Ref_Count_Base&); +}; + +#if defined (__ACE_INLINE__) +#include "Intrusive_Ref_Count_Base_T.inl" +#endif /* __ACE_INLINE__ */ + +#if defined (ACE_TEMPLATES_REQUIRE_SOURCE) +#include "Intrusive_Ref_Count_Base_T.cpp" +#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ + +#if defined (ACE_TEMPLATES_REQUIRE_PRAGMA) +#pragma implementation ("Intrusive_Ref_Count_Base_T.cpp") +#endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */ + +#include /**/ "ace/post.h" + +#endif /* TAO_INTRUSIVE_REF_COUNT_BASE_T_H */ |