Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

TAO_Condition Class Template Reference

Same as to the ACE_Condition variable wrapper. More...

#include <Condition.h>

Inheritance diagram for TAO_Condition:

Inheritance graph
[legend]
Collaboration diagram for TAO_Condition:

Collaboration graph
[legend]
List of all members.

Public Types

typedef MUTEX LOCK
 Useful typedef. More...


Public Methods

 TAO_Condition (MUTEX &m)
 Initialize the condition variable. More...

 TAO_Condition (void)
 A default constructor. Since no lock is provided by the user, one will be created internally. More...

 ~TAO_Condition (void)
 Implicitly destroy the condition variable. More...

int wait (const ACE_Time_Value *abstime)
int wait (void)
 Block on condition. More...

int wait (MUTEX &mutex, const ACE_Time_Value *abstime=0)
int signal (void)
 Signal one waiting thread. More...

int broadcast (void)
 Signal *all* waiting threads. More...

int remove (void)
 Explicitly destroy the condition variable. More...

MUTEX * mutex (void)
 Returns a reference to the underlying mutex_;. More...


Private Methods

void operator= (const TAO_Condition< MUTEX > &)
 TAO_Condition (const TAO_Condition< MUTEX > &)

Private Attributes

MUTEX * mutex_
 Reference to mutex lock. More...

int delete_lock_
 A flag to indicate whether the lock needs to be deleted. More...

TAO_SYNCH_CONDITION * cond_
 Condition variable. More...


Detailed Description

template<class MUTEX>
class TAO_Condition< MUTEX >

Same as to the ACE_Condition variable wrapper.

This class differs from ACE_Condition in that it uses a TAO_SYNCH_CONDITION instead of ACE_cond_t under the hood to provide blocking.

Definition at line 38 of file Condition.h.


Member Typedef Documentation

template<class MUTEX>
typedef MUTEX TAO_Condition::LOCK
 

Useful typedef.

Definition at line 43 of file Condition.h.


Constructor & Destructor Documentation

template<class MUTEX>
TAO_Condition< MUTEX >::TAO_Condition MUTEX &    m
 

Initialize the condition variable.

Definition at line 16 of file Condition.cpp.

References ACE_NEW, and TAO_SYNCH_CONDITION.

00018   : mutex_ (&m),
00019     delete_lock_ (0),
00020     cond_ (0)
00021 {
00022   // @@todo: Need to add the allocatore here..
00023   ACE_NEW (this->cond_,
00024            TAO_SYNCH_CONDITION (*this->mutex_));
00025 }

template<class MUTEX>
TAO_Condition< MUTEX >::TAO_Condition void   
 

A default constructor. Since no lock is provided by the user, one will be created internally.

Definition at line 28 of file Condition.cpp.

References ACE_NEW, delete_lock_, and TAO_SYNCH_CONDITION.

00029     : mutex_ (0),
00030       delete_lock_ (0),
00031       cond_ (0)
00032 
00033 {
00034   // @@todo: Need to add the allocatore here..
00035 
00036   ACE_NEW (this->mutex_,
00037            MUTEX);
00038 
00039   this->delete_lock_ = 1;
00040 
00041   ACE_NEW (this->cond_,
00042            TAO_SYNCH_CONDITION (*this->mutex_));
00043 }

template<class MUTEX>
TAO_Condition< MUTEX >::~TAO_Condition void   
 

Implicitly destroy the condition variable.

Definition at line 47 of file Condition.cpp.

References ACE_ERROR, ACE_LIB_TEXT, cond_, delete_lock_, LM_ERROR, mutex_, and remove.

00048 {
00049   if (this->remove () == -1)
00050     ACE_ERROR ((LM_ERROR,
00051                 ACE_LIB_TEXT ("%p\n"),
00052                 ACE_LIB_TEXT ("TAO_Condition::~TAO_Condition")));
00053 
00054   delete this->cond_;
00055 
00056   if (this->delete_lock_)
00057     delete this->mutex_;
00058 }

template<class MUTEX>
TAO_Condition< MUTEX >::TAO_Condition const TAO_Condition< MUTEX > &    [private]
 


Member Function Documentation

template<class MUTEX>
ACE_INLINE int TAO_Condition< MUTEX >::broadcast void   
 

Signal *all* waiting threads.

Definition at line 46 of file Condition.inl.

References cond_.

00047 {
00048   return this->cond_->broadcast ();
00049 }

template<class MUTEX>
ACE_INLINE MUTEX * TAO_Condition< MUTEX >::mutex void   
 

Returns a reference to the underlying mutex_;.

Definition at line 34 of file Condition.inl.

References mutex_.

Referenced by wait.

00035 {
00036   return this->mutex_;
00037 }

template<class MUTEX>
void TAO_Condition< MUTEX >::operator= const TAO_Condition< MUTEX > &    [private]
 

template<class MUTEX>
ACE_INLINE int TAO_Condition< MUTEX >::remove void   
 

Explicitly destroy the condition variable.

Definition at line 28 of file Condition.inl.

References cond_.

Referenced by ~TAO_Condition.

00029 {
00030   return this->cond_->remove ();
00031 }

template<class MUTEX>
ACE_INLINE int TAO_Condition< MUTEX >::signal void   
 

Signal one waiting thread.

Definition at line 40 of file Condition.inl.

References cond_.

00041 {
00042   return this->cond_->signal ();
00043 }

template<class MUTEX>
ACE_INLINE int TAO_Condition< MUTEX >::wait MUTEX &    mutex,
const ACE_Time_Value   abstime = 0
 

Block on condition or until absolute time-of-day has passed. If abstime == 0 use "blocking" wait() semantics on the <mutex> passed as a parameter (this is useful if you need to store the <Condition> in shared memory). Else, if <abstime> != 0 and the call times out before the condition is signaled <wait> returns -1 and sets errno to ETIME.

Definition at line 10 of file Condition.inl.

References cond_, and mutex.

00012 {
00013   return this->cond_->wait (mutex,
00014                            abstime);
00015 }

template<class MUTEX>
ACE_INLINE int TAO_Condition< MUTEX >::wait void   
 

Block on condition.

Definition at line 4 of file Condition.inl.

References cond_.

Referenced by wait.

00005 {
00006   return this->cond_->wait ();
00007 }

template<class MUTEX>
ACE_INLINE int TAO_Condition< MUTEX >::wait const ACE_Time_Value   abstime
 

Block on condition, or until absolute time-of-day has passed. If abstime == 0 use "blocking" <wait> semantics. Else, if <abstime> != 0 and the call times out before the condition is signaled <wait> returns -1 and sets errno to ETIME.

Definition at line 22 of file Condition.inl.

References wait.

00023 {
00024   return this->wait (*this->mutex_, abstime);
00025 }


Member Data Documentation

template<class MUTEX>
TAO_SYNCH_CONDITION* TAO_Condition::cond_ [private]
 

Condition variable.

Definition at line 100 of file Condition.h.

Referenced by broadcast, remove, signal, wait, and ~TAO_Condition.

template<class MUTEX>
int TAO_Condition::delete_lock_ [private]
 

A flag to indicate whether the lock needs to be deleted.

Definition at line 97 of file Condition.h.

Referenced by TAO_Condition, and ~TAO_Condition.

template<class MUTEX>
MUTEX* TAO_Condition::mutex_ [private]
 

Reference to mutex lock.

Definition at line 94 of file Condition.h.

Referenced by mutex, and ~TAO_Condition.


The documentation for this class was generated from the following files:
Generated on Mon Jun 16 15:09:52 2003 for TAO by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002