00001 // -*- C++ -*- 00002 00003 //============================================================================= 00004 /** 00005 * @file Refcountable_T.h 00006 * 00007 * $Id: Refcountable_T.h 81409 2008-04-24 08:30:48Z johnnyw $ 00008 * 00009 * @author Doug Schmidt 00010 * @author Johnny Willemsen 00011 */ 00012 //============================================================================= 00013 #ifndef ACE_REFCOUNTABLE_T_H 00014 #define ACE_REFCOUNTABLE_T_H 00015 #include /**/ "ace/pre.h" 00016 00017 #include /**/ "ace/ACE_export.h" 00018 00019 #if !defined (ACE_LACKS_PRAGMA_ONCE) 00020 # pragma once 00021 #endif /* ACE_LACKS_PRAGMA_ONCE */ 00022 00023 #include "ace/Atomic_Op.h" 00024 #include "ace/Synch_Traits.h" 00025 00026 ACE_BEGIN_VERSIONED_NAMESPACE_DECL 00027 00028 template <class ACE_LOCK> 00029 class ACE_Refcountable_T 00030 { 00031 public: 00032 /// Destructor. 00033 virtual ~ACE_Refcountable_T (void); 00034 00035 // = Increment/Decrement refcount 00036 long increment (void); 00037 long decrement (void); 00038 00039 /// Returns the current refcount. 00040 long refcount (void) const; 00041 00042 protected: 00043 /// Protected constructor. 00044 ACE_Refcountable_T (long refcount); 00045 00046 /// Current refcount. 00047 ACE_Atomic_Op <ACE_LOCK, long> refcount_; 00048 }; 00049 00050 typedef ACE_Refcountable_T<ACE_Null_Mutex> ACE_Refcountable; 00051 00052 ACE_END_VERSIONED_NAMESPACE_DECL 00053 00054 #if defined (__ACE_INLINE__) 00055 #include "ace/Refcountable_T.inl" 00056 #endif /* __ACE_INLINE__ */ 00057 00058 #if defined (ACE_TEMPLATES_REQUIRE_SOURCE) 00059 #include "ace/Refcountable_T.cpp" 00060 #endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ 00061 00062 #if defined (ACE_TEMPLATES_REQUIRE_PRAGMA) 00063 #pragma implementation ("Refcountable_T.cpp") 00064 #endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */ 00065 00066 #include /**/ "ace/post.h" 00067 #endif /*ACE_REFCOUNTABLE_T_H*/