Updated logging to include the class/method so that it is more obvious where these...
[ACE_TAO.git] / TAO / tao / Condition.h
blobf89649345d694d66db6d74d0c0b748db01333038
1 // -*- C++ -*-
3 //=============================================================================
4 /**
5 * @file Condition.h
7 * @author From ACE to TAO by Balachandran Natarajan <bala@cs.wustl.edu>
8 */
9 //=============================================================================
11 #ifndef TAO_CONDITION_H
12 #define TAO_CONDITION_H
14 #include /**/ "ace/pre.h"
16 #include "tao/orbconf.h"
18 #if !defined (ACE_LACKS_PRAGMA_ONCE)
19 # pragma once
20 #endif /* ACE_LACKS_PRAGMA_ONCE */
22 #include "ace/Condition_T.h"
23 #include "ace/Global_Macros.h"
25 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
26 class ACE_Time_Value;
27 ACE_END_VERSIONED_NAMESPACE_DECL
29 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
31 /**
32 * @class TAO_Condition
34 * @brief Same as to the ACE_Condition variable wrapper
36 * This class differs from ACE_Condition in that it uses a
37 * TAO_SYNCH_CONDITION instead of ACE_cond_t under the hood to
38 * provide blocking.
40 template <class MUTEX>
41 class TAO_Condition
43 public:
44 /// Useful typedef
45 typedef MUTEX LOCK;
47 // = Initialiation and termination methods.
48 /// Initialize the condition variable.
49 TAO_Condition (MUTEX &m);
51 /// A default constructor. Since no lock is provided by the user,
52 /// one will be created internally.
53 TAO_Condition ();
55 /// Implicitly destroy the condition variable.
56 ~TAO_Condition ();
58 // = Lock accessors.
59 /**
60 * Block on condition, or until absolute time-of-day has passed. If
61 * abstime == 0 use "blocking" <wait> semantics. Else, if <abstime>
62 * != 0 and the call times out before the condition is signaled
63 * <wait> returns -1 and sets errno to ETIME.
65 int wait (const ACE_Time_Value *abstime);
67 /// Block on condition.
68 int wait ();
70 /**
71 * Block on condition or until absolute time-of-day has passed. If
72 * abstime == 0 use "blocking" wait() semantics on the <mutex>
73 * passed as a parameter (this is useful if you need to store the
74 * <Condition> in shared memory). Else, if <abstime> != 0 and the
75 * call times out before the condition is signaled <wait> returns -1
76 * and sets errno to ETIME.
78 int wait (MUTEX &mutex, const ACE_Time_Value *abstime = 0);
80 /// Signal one waiting thread.
81 int signal ();
83 /// Signal *all* waiting threads.
84 int broadcast ();
86 // = Utility methods.
87 /// Explicitly destroy the condition variable.
88 int remove ();
90 /// Returns a reference to the underlying mutex_;
91 MUTEX *mutex ();
93 private:
94 TAO_Condition (const TAO_Condition<MUTEX> &) = delete;
95 TAO_Condition &operator= (const TAO_Condition<MUTEX> &) = delete;
97 /// Reference to mutex lock.
98 MUTEX *mutex_;
100 /// A flag to indicate whether the lock needs to be deleted.
101 bool delete_lock_;
103 /// Condition variable.
104 TAO_SYNCH_CONDITION *cond_;
107 TAO_END_VERSIONED_NAMESPACE_DECL
109 #if defined (__ACE_INLINE__)
110 #include "tao/Condition.inl"
111 #endif /* __ACE_INLINE__ */
113 #if defined (ACE_TEMPLATES_REQUIRE_SOURCE)
114 #include "tao/Condition.cpp"
115 #endif /* ACE_TEMPLATES_REQUIRE_SOURCE */
117 #if defined (ACE_TEMPLATES_REQUIRE_PRAGMA)
118 #pragma implementation ("Condition.cpp")
119 #endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */
121 #include /**/ "ace/post.h"
122 #endif /*TAO_CONDITION_H*/