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

Condition.h

Go to the documentation of this file.
00001 /* -*- C++ -*- */
00002 
00003 //=============================================================================
00004 /**
00005  *  @file    Condition.h
00006  *
00007  *  $Id: Condition.h,v 1.1.1.1 2003/02/21 18:36:44 chad Exp $
00008  *
00009  *  @author From ACE to TAO by Balachandran Natarajan <bala@cs.wustl.edu>
00010  */
00011 //=============================================================================
00012 
00013 #ifndef TAO_CONDITION_H
00014 #define TAO_CONDITION_H
00015 #include "ace/pre.h"
00016 #include "orbconf.h"
00017 #include "ace/Synch_T.h"
00018 
00019 #if !defined (ACE_LACKS_PRAGMA_ONCE)
00020 # pragma once
00021 #endif /* ACE_LACKS_PRAGMA_ONCE */
00022 #include "ace/Synch_T.h"
00023 #include "ace/Global_Macros.h"
00024 
00025 class ACE_Time_Value;
00026 
00027 
00028 /**
00029  * @class TAO_Condition
00030  *
00031  * @brief Same as to the ACE_Condition variable wrapper
00032  *
00033  * This class differs from ACE_Condition in that it uses a
00034  * TAO_SYNCH_CONDITION instead of ACE_cond_t  under the hood to
00035  * provide blocking.
00036  */
00037 template <class MUTEX>
00038 class TAO_Condition
00039 {
00040 public:
00041 
00042   /// Useful typedef
00043   typedef MUTEX LOCK;
00044 
00045   // = Initialiation and termination methods.
00046   /// Initialize the condition variable.
00047   TAO_Condition (MUTEX &m);
00048 
00049   /// A default constructor. Since no lock is provided by the user,
00050   /// one will be created internally.
00051   TAO_Condition (void);
00052 
00053   /// Implicitly destroy the condition variable.
00054   ~TAO_Condition (void);
00055 
00056   // = Lock accessors.
00057   /**
00058    * Block on condition, or until absolute time-of-day has passed.  If
00059    * abstime == 0 use "blocking" <wait> semantics.  Else, if <abstime>
00060    * != 0 and the call times out before the condition is signaled
00061    * <wait> returns -1 and sets errno to ETIME.
00062    */
00063   int wait (const ACE_Time_Value *abstime);
00064 
00065   /// Block on condition.
00066   int wait (void);
00067 
00068   /**
00069    * Block on condition or until absolute time-of-day has passed.  If
00070    * abstime == 0 use "blocking" wait() semantics on the <mutex>
00071    * passed as a parameter (this is useful if you need to store the
00072    * <Condition> in shared memory).  Else, if <abstime> != 0 and the
00073    * call times out before the condition is signaled <wait> returns -1
00074    * and sets errno to ETIME.
00075    */
00076   int wait (MUTEX &mutex, const ACE_Time_Value *abstime = 0);
00077 
00078   /// Signal one waiting thread.
00079   int signal (void);
00080 
00081   /// Signal *all* waiting threads.
00082   int broadcast (void);
00083 
00084   // = Utility methods.
00085   /// Explicitly destroy the condition variable.
00086   int remove (void);
00087 
00088   /// Returns a reference to the underlying mutex_;
00089   MUTEX *mutex (void);
00090 
00091 private:
00092 
00093   /// Reference to mutex lock.
00094   MUTEX *mutex_;
00095 
00096   /// A flag to indicate whether the lock needs to be deleted.
00097   int delete_lock_;
00098 
00099   /// Condition variable.
00100   TAO_SYNCH_CONDITION *cond_;
00101 
00102   // = Prevent assignment and initialization.
00103   ACE_UNIMPLEMENTED_FUNC (void operator= (const TAO_Condition<MUTEX> &))
00104   ACE_UNIMPLEMENTED_FUNC (TAO_Condition (const TAO_Condition<MUTEX> &))
00105 };
00106 
00107 #if defined (__ACE_INLINE__)
00108 #include "Condition.inl"
00109 #endif /* __ACE_INLINE__ */
00110 
00111 #if defined (ACE_TEMPLATES_REQUIRE_SOURCE)
00112 #include "Condition.cpp"
00113 #endif /* ACE_TEMPLATES_REQUIRE_SOURCE */
00114 
00115 #if defined (ACE_TEMPLATES_REQUIRE_PRAGMA)
00116 #pragma implementation ("Condition.cpp")
00117 #endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */
00118 
00119 #include "ace/post.h"
00120 #endif /*TAO_CONDITION_H*/

Generated on Mon Jun 16 13:48:05 2003 for TAO by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002