00001 // -*- C++ -*- 00002 00003 //============================================================================= 00004 /** 00005 * @file RT_Mutex.h 00006 * 00007 * RT_Mutex.h,v 1.11 2006/03/10 07:19:16 jtc Exp 00008 * 00009 * @author Frank Hunleth <fhunleth@cs.wustl.edu> 00010 */ 00011 //============================================================================= 00012 00013 00014 #ifndef TAO_RT_MUTEX_H 00015 #define TAO_RT_MUTEX_H 00016 00017 #include /**/ "ace/pre.h" 00018 #include "tao/orbconf.h" 00019 00020 #if defined (TAO_HAS_CORBA_MESSAGING) && TAO_HAS_CORBA_MESSAGING != 0 00021 00022 #if !defined (ACE_LACKS_PRAGMA_ONCE) 00023 # pragma once 00024 #endif /* ACE_LACKS_PRAGMA_ONCE */ 00025 00026 #define TAO_RTCORBA_SAFE_INCLUDE 00027 #include "tao/RTCORBA/RTCORBAC.h" 00028 #undef TAO_RTCORBA_SAFE_INCLUDE 00029 00030 #include "tao/LocalObject.h" 00031 00032 #if (TAO_HAS_NAMED_RT_MUTEXES == 1) 00033 # include "ace/SString.h" 00034 #endif /* TAO_HAS_NAMED_RT_MUTEXES == 1 */ 00035 00036 #if defined(_MSC_VER) 00037 #pragma warning(push) 00038 #pragma warning(disable:4250) 00039 #endif /* _MSC_VER */ 00040 00041 TAO_BEGIN_VERSIONED_NAMESPACE_DECL 00042 00043 /** 00044 * @class TAO_RT_Mutex 00045 * 00046 * @brief Abstract base class for the TAO RT Mutex implementations 00047 * 00048 * This class just serves as a base class for any of the TAO 00049 * RT Mutex implementations. Instances of these classes should 00050 * be created using the RTCORBA::create_mutex() method. 00051 * 00052 */ 00053 00054 class TAO_RTCORBA_Export TAO_RT_Mutex 00055 : public RTCORBA::Mutex, 00056 public TAO_Local_RefCounted_Object 00057 { 00058 public: 00059 00060 /// Acquire the lock. 00061 virtual void lock (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) 00062 ACE_THROW_SPEC ((CORBA::SystemException)); 00063 00064 /// Release the lock. 00065 virtual void unlock (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) 00066 ACE_THROW_SPEC ((CORBA::SystemException)); 00067 00068 /** 00069 * Acquire the lock, but only wait up to @a max_wait time. Note 00070 * that this operation may not be available on all OS platforms, so 00071 * if you're interested in writing maximally portable programs avoid 00072 * using this operation in your program designs. 00073 */ 00074 virtual CORBA::Boolean try_lock (TimeBase::TimeT max_wait 00075 ACE_ENV_ARG_DECL_WITH_DEFAULTS) 00076 ACE_THROW_SPEC ((CORBA::SystemException)); 00077 00078 /// Returns the name of the mutex. 00079 virtual const char *name (void) const; 00080 00081 protected: 00082 00083 /// Destructor. 00084 virtual ~TAO_RT_Mutex (void); 00085 00086 protected: 00087 /// Synchronization lock. 00088 TAO_SYNCH_MUTEX mu_; 00089 }; 00090 00091 #if (TAO_HAS_NAMED_RT_MUTEXES == 1) 00092 /** 00093 * @class TAO_Named_RT_Mutex 00094 * 00095 * @brief Extension to TAO_RT_Mutex to support named mutexes. 00096 * 00097 */ 00098 class TAO_RTCORBA_Export TAO_Named_RT_Mutex : public TAO_RT_Mutex 00099 { 00100 public: 00101 /// Constructor. 00102 TAO_Named_RT_Mutex (const char *name); 00103 00104 /// Returns the name of the mutex. 00105 virtual const char *name (void) const; 00106 00107 protected: 00108 00109 /// My name. 00110 ACE_CString name_; 00111 }; 00112 #endif /* TAO_HAS_NAMED_RT_MUTEXES == 1 */ 00113 00114 TAO_END_VERSIONED_NAMESPACE_DECL 00115 00116 #if defined(_MSC_VER) 00117 #pragma warning(pop) 00118 #endif /* _MSC_VER */ 00119 00120 #endif /* TAO_HAS_CORBA_MESSAGING && TAO_HAS_CORBA_MESSAGING != 0 */ 00121 00122 #include /**/ "ace/post.h" 00123 #endif /* TAO_RT_MUTEX_H */