00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #include "ace/Condition_Thread_Mutex.h"
00013
00014 #if defined (ACE_HAS_THREADS)
00015
00016 #if !defined (__ACE_INLINE__)
00017 #include "ace/Condition_Thread_Mutex.inl"
00018 #endif
00019
00020 #include "ace/Log_Msg.h"
00021
00022 ACE_RCSID(ace, Condition_Thread_Mutex, "Condition_Thread_Mutex.cpp,v 4.6 2006/05/30 10:19:18 jwillemsen Exp")
00023
00024 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
00025
00026 ACE_ALLOC_HOOK_DEFINE(ACE_Condition_Thread_Mutex)
00027
00028 void
00029 ACE_Condition_Thread_Mutex::dump (void) const
00030 {
00031 #if defined (ACE_HAS_DUMP)
00032
00033
00034 ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
00035 ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("\n")));
00036 #if defined (ACE_WIN32)
00037 ACE_DEBUG ((LM_DEBUG,
00038 ACE_LIB_TEXT ("waiters = %d\n"),
00039 this->cond_.waiters ()));
00040 #endif
00041 ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
00042 #endif
00043 }
00044
00045 ACE_Condition_Thread_Mutex::ACE_Condition_Thread_Mutex (const ACE_Thread_Mutex &m,
00046 const ACE_TCHAR *name,
00047 void *arg)
00048 : mutex_ ((ACE_Thread_Mutex &) m),
00049 removed_ (0)
00050 {
00051
00052 if (ACE_OS::cond_init (&this->cond_,
00053 (short) USYNC_THREAD,
00054 name,
00055 arg) != 0)
00056 ACE_ERROR ((LM_ERROR,
00057 ACE_LIB_TEXT ("%p\n"),
00058 ACE_LIB_TEXT ("ACE_Condition_Thread_Mutex::ACE_Condition_Thread_Mutex")));
00059 }
00060
00061 ACE_Condition_Thread_Mutex::
00062 ACE_Condition_Thread_Mutex (const ACE_Thread_Mutex &m,
00063 ACE_Condition_Attributes &attributes,
00064 const ACE_TCHAR *name,
00065 void *arg)
00066 : mutex_ ((ACE_Thread_Mutex &) m),
00067 removed_ (0)
00068 {
00069
00070 if (ACE_OS::cond_init (&this->cond_, attributes.attributes_,
00071 name, arg) != 0)
00072 ACE_ERROR ((LM_ERROR, ACE_LIB_TEXT ("%p\n"),
00073 ACE_LIB_TEXT ("ACE_Condition_Thread_Mutex::ACE_Condition_Thread_Mutex")));
00074 }
00075
00076 ACE_Condition_Thread_Mutex::~ACE_Condition_Thread_Mutex (void)
00077 {
00078
00079 this->remove ();
00080 }
00081
00082
00083
00084
00085
00086 int
00087 ACE_Condition_Thread_Mutex::wait (void)
00088 {
00089
00090 return ACE_OS::cond_wait (&this->cond_, &this->mutex_.lock_);
00091 }
00092
00093 int
00094 ACE_Condition_Thread_Mutex::wait (ACE_Thread_Mutex &mutex,
00095 const ACE_Time_Value *abstime)
00096 {
00097
00098 return ACE_OS::cond_timedwait (&this->cond_,
00099 &mutex.lock_,
00100 const_cast <ACE_Time_Value *> (abstime));
00101 }
00102
00103 int
00104 ACE_Condition_Thread_Mutex::wait (const ACE_Time_Value *abstime)
00105 {
00106
00107 return this->wait (this->mutex_, abstime);
00108 }
00109
00110 int
00111 ACE_Condition_Thread_Mutex::signal (void)
00112 {
00113
00114 return ACE_OS::cond_signal (&this->cond_);
00115 }
00116
00117 int
00118 ACE_Condition_Thread_Mutex::broadcast (void)
00119 {
00120
00121 return ACE_OS::cond_broadcast (&this->cond_);
00122 }
00123
00124 ACE_END_VERSIONED_NAMESPACE_DECL
00125
00126 #endif