#include <Condition_T.h>
Inheritance diagram for ACE_Condition< MUTEX >:
Public Member Functions | |
ACE_Condition (MUTEX &m, int type=USYNC_THREAD, const ACE_TCHAR *name=0, void *arg=0) | |
Initialize the condition variable. | |
~ACE_Condition (void) | |
Implicitly destroy the condition variable. | |
int | wait (const ACE_Time_Value *abstime) |
int | wait (void) |
Block on condition. | |
int | wait (MUTEX &mutex, const ACE_Time_Value *abstime=0) |
int | signal (void) |
Signal one waiting thread. | |
int | broadcast (void) |
Signal *all* waiting threads. | |
int | remove (void) |
Explicitly destroy the condition variable. | |
MUTEX & | mutex (void) |
Returns a reference to the underlying mutex_;. | |
void | dump (void) const |
Dump the state of an object. | |
Protected Attributes | |
ACE_cond_t | cond_ |
Condition variable. | |
MUTEX & | mutex_ |
Reference to mutex lock. | |
Private Member Functions | |
void | operator= (const ACE_Condition< MUTEX > &) |
ACE_Condition (const ACE_Condition< MUTEX > &) |
A condition variable enables threads to atomically block and test the condition under the protection of a mutual exclu- sion lock (mutex) until the condition is satisfied. That is, the mutex must have been held by the thread before calling wait or signal on the condition. If the condition is false, a thread blocks on a condition variable and atomically releases the mutex that is waiting for the condition to change. If another thread changes the condition, it may wake up waiting threads by signaling the associated condition variable. The waiting threads, upon awakening, reacquire the mutex and re-evaluate the condition. Note, you can only parameterize with ACE_Thread_Mutex, ACE_Recursive_Thread_Mutex, or ACE_Null_Mutex.
Definition at line 54 of file Condition_T.h.
|
Initialize the condition variable.
Definition at line 56 of file Condition_T.cpp. References ACE_ERROR, ACE_LIB_TEXT, ACE_TCHAR, ACE_OS::cond_init(), and LM_ERROR.
00060 : 00061 mutex_ (m) 00062 { 00063 // ACE_TRACE ("ACE_Condition<MUTEX>::ACE_Condition"); 00064 00065 if (ACE_OS::cond_init (&this->cond_, 00066 (short) type, 00067 name, 00068 arg) != 0) 00069 ACE_ERROR ((LM_ERROR, 00070 ACE_LIB_TEXT ("%p\n"), 00071 ACE_LIB_TEXT ("ACE_Condition::ACE_Condition"))); 00072 } |
|
Implicitly destroy the condition variable.
Definition at line 75 of file Condition_T.cpp. References ACE_ERROR, ACE_LIB_TEXT, LM_ERROR, and ACE_Condition< MUTEX >::remove().
|
|
|
|
Signal *all* waiting threads.
Definition at line 45 of file Condition_T.inl. References ACE_OS::cond_broadcast().
00046 { 00047 // ACE_TRACE ("ACE_Condition<MUTEX>::broadcast"); 00048 return ACE_OS::cond_broadcast (&this->cond_); 00049 } |
|
Dump the state of an object.
Reimplemented in ACE_Thread_Condition< MUTEX >, and ACE_Thread_Condition< ACE_Thread_Mutex >. Definition at line 25 of file Condition_T.cpp. References ACE_BEGIN_DUMP, ACE_DEBUG, ACE_END_DUMP, ACE_LIB_TEXT, and LM_DEBUG. Referenced by ACE_Thread_Condition< MUTEX >::dump().
|
|
Returns a reference to the underlying mutex_;.
Definition at line 31 of file Condition_T.inl.
00032 { 00033 // ACE_TRACE ("ACE_Condition<MUTEX>::mutex"); 00034 return this->mutex_; 00035 } |
|
|
|
Explicitly destroy the condition variable.
Definition at line 8 of file Condition_T.inl. References ACE_OS::cond_broadcast(), ACE_OS::cond_destroy(), EBUSY, and ACE_OS::thr_yield(). Referenced by ACE_Condition< MUTEX >::~ACE_Condition(), and ACE_Condition< ACE_Recursive_Thread_Mutex >::~ACE_Condition().
00009 { 00010 // ACE_TRACE ("ACE_Condition<MUTEX>::remove"); 00011 00012 // cond_destroy() is called in a loop if the condition variable is 00013 // BUSY. This avoids a condition where a condition is signaled and 00014 // because of some timing problem, the thread that is to be signaled 00015 // has called the cond_wait routine after the signal call. Since 00016 // the condition signal is not queued in any way, deadlock occurs. 00017 00018 int result = 0; 00019 00020 while ((result = ACE_OS::cond_destroy (&this->cond_)) == -1 00021 && errno == EBUSY) 00022 { 00023 ACE_OS::cond_broadcast (&this->cond_); 00024 ACE_OS::thr_yield (); 00025 } 00026 00027 return result; 00028 } |
|
Signal one waiting thread.
Definition at line 38 of file Condition_T.inl. References ACE_OS::cond_signal().
00039 { 00040 // ACE_TRACE ("ACE_Condition<MUTEX>::signal"); 00041 return ACE_OS::cond_signal (&this->cond_); 00042 } |
|
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_T.cpp. References ACE_OS::cond_timedwait(), and ACE_Condition< MUTEX >::wait().
00096 { 00097 // ACE_TRACE ("ACE_Condition<MUTEX>::wait"); 00098 if (abstime == 0) 00099 return this->wait (); 00100 else 00101 { 00102 return ACE_OS::cond_timedwait (&this->cond_, 00103 &mutex.lock_, 00104 (ACE_Time_Value *) abstime); 00105 } 00106 } |
|
Block on condition.
Definition at line 86 of file Condition_T.cpp. References ACE_OS::cond_wait(). Referenced by ACE_Condition< MUTEX >::wait(), and ACE_Condition< ACE_Recursive_Thread_Mutex >::wait().
00087 { 00088 // ACE_TRACE ("ACE_Condition<MUTEX>::wait"); 00089 return ACE_OS::cond_wait (&this->cond_, 00090 &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 113 of file Condition_T.cpp. References ACE_Condition< MUTEX >::wait().
00114 { 00115 // ACE_TRACE ("ACE_Condition<MUTEX>::wait"); 00116 return this->wait (this->mutex_, abstime); 00117 } |
|
Condition variable.
Definition at line 108 of file Condition_T.h. |
|
Reference to mutex lock.
Definition at line 111 of file Condition_T.h. |