00001 // This may look like C, but it's really 00002 // -*- C++ -*- 00003 00004 //============================================================================= 00005 /** 00006 * @file Configurable_Refcount.h 00007 * 00008 * $Id: Configurable_Refcount.h 74014 2006-08-14 13:52:22Z johnnyw $ 00009 * 00010 * Definition for a synchronised refcountable interface. 00011 * 00012 * @author Fred Kuhns <fredk@cs.wustl.edu> 00013 */ 00014 //============================================================================= 00015 00016 #ifndef TAO_CONFIGURABLE_REFCOUNT_H 00017 #define TAO_CONFIGURABLE_REFCOUNT_H 00018 00019 #include /**/ "ace/pre.h" 00020 #include "ace/Atomic_Op.h" 00021 00022 #if !defined (ACE_LACKS_PRAGMA_ONCE) 00023 # pragma once 00024 #endif /* ACE_LACKS_PRAGMA_ONCE */ 00025 00026 #include "ace/Null_Mutex.h" 00027 #include /**/ "tao/TAO_Export.h" 00028 #include "tao/orbconf.h" 00029 00030 TAO_BEGIN_VERSIONED_NAMESPACE_DECL 00031 00032 /** 00033 * @class TAO_Configurable_Refcount 00034 * 00035 * @brief Definition for a synchronised refcountable interface. 00036 */ 00037 class TAO_Export TAO_Configurable_Refcount 00038 { 00039 public: 00040 enum Lock_Type 00041 { 00042 TAO_NULL_LOCK, 00043 TAO_THREAD_LOCK 00044 }; 00045 00046 TAO_Configurable_Refcount (Lock_Type type = TAO_THREAD_LOCK, 00047 unsigned long value = 1); 00048 00049 unsigned long increment (void); 00050 unsigned long decrement (void); 00051 00052 unsigned long value (void) const; 00053 00054 private: 00055 Lock_Type type_; 00056 ACE_Atomic_Op<ACE_SYNCH_NULL_MUTEX, unsigned long> null_refcount_; 00057 ACE_Atomic_Op<TAO_SYNCH_MUTEX, unsigned long> mutex_refcount_; 00058 }; 00059 00060 00061 TAO_END_VERSIONED_NAMESPACE_DECL 00062 00063 #if defined (__ACE_INLINE__) 00064 # include "Configurable_Refcount.inl" 00065 #endif /* __ACE_INLINE__ */ 00066 00067 #include /**/ "ace/post.h" 00068 00069 #endif /* TAO_CONFIGURABLE_REFCOUNT */