#include <Condition_Thread_Mutex.h>
Collaboration diagram for ACE_Condition_Thread_Mutex:
Public Member Functions | |
ACE_Condition_Thread_Mutex (const ACE_Thread_Mutex &m, const ACE_TCHAR *name=0, void *arg=0) | |
Initialize the condition variable. | |
ACE_Condition_Thread_Mutex (const ACE_Thread_Mutex &m, ACE_Condition_Attributes &attributes, const ACE_TCHAR *name=0, void *arg=0) | |
Initialize the condition variable. | |
~ACE_Condition_Thread_Mutex (void) | |
Implicitly destroy the condition variable. | |
int | remove (void) |
int | wait (const ACE_Time_Value *abstime) |
int | wait (void) |
Block on condition. | |
int | wait (ACE_Thread_Mutex &mutex, const ACE_Time_Value *abstime=0) |
int | signal (void) |
Signal one waiting thread. | |
int | broadcast (void) |
Signal *all* waiting threads. | |
ACE_Thread_Mutex & | mutex (void) |
Returns a reference to the underlying mutex;. | |
void | dump (void) const |
Dump the state of an object. | |
Public Attributes | |
ACE_ALLOC_HOOK_DECLARE | |
Declare the dynamic allocation hooks. | |
Protected Attributes | |
ACE_cond_t | cond_ |
Condition variable. | |
ACE_Thread_Mutex & | mutex_ |
Reference to mutex lock. | |
int | removed_ |
Private Member Functions | |
void | operator= (const ACE_Condition_Thread_Mutex &) |
ACE_Condition_Thread_Mutex (const ACE_Condition_Thread_Mutex &) |
This should be an instantiation of ACE_Condition but problems with compilers precludes this...
Definition at line 77 of file Condition_Thread_Mutex.h.
|
Initialize the condition variable.
Definition at line 45 of file Condition_Thread_Mutex.cpp. References ACE_ERROR, ACE_LIB_TEXT, ACE_TCHAR, ACE_OS::cond_init(), and LM_ERROR.
00048 : mutex_ ((ACE_Thread_Mutex &) m), 00049 removed_ (0) 00050 { 00051 // ACE_TRACE ("ACE_Condition_Thread_Mutex::ACE_Condition_Thread_Mutex"); 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 } |
|
Initialize the condition variable.
Definition at line 62 of file Condition_Thread_Mutex.cpp. References ACE_ERROR, ACE_LIB_TEXT, ACE_TCHAR, ACE_Condition_Attributes::attributes_, ACE_OS::cond_init(), and LM_ERROR.
00066 : mutex_ ((ACE_Thread_Mutex &) m), 00067 removed_ (0) 00068 { 00069 // ACE_TRACE ("ACE_Condition_Thread_Mutex::ACE_Condition_Thread_Mutex"); 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 } |
|
Implicitly destroy the condition variable.
Definition at line 76 of file Condition_Thread_Mutex.cpp. References remove().
00077 { 00078 // ACE_TRACE ("ACE_Condition_Thread_Mutex::~ACE_Condition_Thread_Mutex"); 00079 this->remove (); 00080 } |
|
|
|
Signal *all* waiting threads.
Definition at line 118 of file Condition_Thread_Mutex.cpp. References ACE_OS::cond_broadcast(). Referenced by ACE_Thread_Manager::remove_thr(), ACE_Barrier::shutdown(), and ACE_Barrier::wait().
00119 { 00120 // ACE_TRACE ("ACE_Condition_Thread_Mutex::broadcast"); 00121 return ACE_OS::cond_broadcast (&this->cond_); 00122 } |
|
Dump the state of an object.
Definition at line 29 of file Condition_Thread_Mutex.cpp. References ACE_BEGIN_DUMP, ACE_DEBUG, ACE_END_DUMP, ACE_LIB_TEXT, and LM_DEBUG. Referenced by ACE_Sub_Barrier::dump().
00030 { 00031 #if defined (ACE_HAS_DUMP) 00032 // ACE_TRACE ("ACE_Condition_Thread_Mutex::dump"); 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 /* ACE_WIN32 */ 00041 ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); 00042 #endif /* ACE_HAS_DUMP */ 00043 } |
|
Returns a reference to the underlying mutex;.
Definition at line 47 of file Condition_Thread_Mutex.inl.
00048 { 00049 // ACE_TRACE ("ACE_Condition_Thread_Mutex::mutex"); 00050 return this->mutex_; 00051 } |
|
|
|
Explicitly destroy the condition variable. Note that only one thread should call this method since it doesn't protect against race conditions. Definition at line 20 of file Condition_Thread_Mutex.inl. References ACE_OS::cond_broadcast(), ACE_OS::cond_destroy(), EBUSY, removed_, and ACE_OS::thr_yield(). Referenced by ~ACE_Condition_Thread_Mutex().
00021 { 00022 // ACE_TRACE ("ACE_Condition_Thread_Mutex::remove"); 00023 00024 // <cond_destroy> is called in a loop if the condition variable is 00025 // BUSY. This avoids a condition where a condition is signaled and 00026 // because of some timing problem, the thread that is to be signaled 00027 // has called the cond_wait routine after the signal call. Since 00028 // the condition signal is not queued in any way, deadlock occurs. 00029 00030 int result = 0; 00031 00032 if (this->removed_ == 0) 00033 { 00034 this->removed_ = 1; 00035 00036 while ((result = ACE_OS::cond_destroy (&this->cond_)) == -1 00037 && errno == EBUSY) 00038 { 00039 ACE_OS::cond_broadcast (&this->cond_); 00040 ACE_OS::thr_yield (); 00041 } 00042 } 00043 return result; 00044 } |
|
Signal one waiting thread.
Definition at line 111 of file Condition_Thread_Mutex.cpp. References ACE_OS::cond_signal().
00112 { 00113 // ACE_TRACE ("ACE_Condition_Thread_Mutex::signal"); 00114 return ACE_OS::cond_signal (&this->cond_); 00115 } |
|
Block on condition or until absolute time-of-day has passed. If abstime == 0 use "blocking" wait() semantics on the passed as a parameter (this is useful if you need to store the in shared memory). Else, if != 0 and the call times out before the condition is signaled returns -1 and sets errno to ETIME. Definition at line 94 of file Condition_Thread_Mutex.cpp. References ACE_OS::cond_timedwait(), and ACE_Thread_Mutex::lock_.
00096 { 00097 // ACE_TRACE ("ACE_Condition_Thread_Mutex::wait"); 00098 return ACE_OS::cond_timedwait (&this->cond_, 00099 &mutex.lock_, 00100 const_cast <ACE_Time_Value *> (abstime)); 00101 } |
|
Block on condition.
Definition at line 87 of file Condition_Thread_Mutex.cpp. References ACE_OS::cond_wait(). Referenced by wait().
00088 { 00089 // ACE_TRACE ("ACE_Condition_Thread_Mutex::wait"); 00090 return ACE_OS::cond_wait (&this->cond_, &this->mutex_.lock_); 00091 } |
|
Block on condition, or until absolute time-of-day has passed. If abstime == 0 use "blocking" semantics. Else, if != 0 and the call times out before the condition is signaled returns -1 and sets errno to ETIME. Definition at line 104 of file Condition_Thread_Mutex.cpp. References wait(). Referenced by ACE_Thread_Manager::wait(), and ACE_Barrier::wait().
00105 { 00106 // ACE_TRACE ("ACE_Condition_Thread_Mutex::wait"); 00107 return this->wait (this->mutex_, abstime); 00108 } |
|
Declare the dynamic allocation hooks.
Definition at line 135 of file Condition_Thread_Mutex.h. |
|
Condition variable.
Definition at line 139 of file Condition_Thread_Mutex.h. |
|
Reference to mutex lock.
Definition at line 142 of file Condition_Thread_Mutex.h. |
|
Keeps track of whether has been called yet to avoid multiple calls, e.g., explicitly and implicitly in the destructor. This flag isn't protected by a lock, so make sure that you don't have multiple threads simultaneously calling on the same object, which is a bad idea anyway... Definition at line 149 of file Condition_Thread_Mutex.h. Referenced by remove(). |