1 #ifndef ACE_CONDITION_T_CPP
2 #define ACE_CONDITION_T_CPP
4 #include "ace/Condition_T.h"
6 #if !defined (ACE_LACKS_PRAGMA_ONCE)
8 #endif /* ACE_LACKS_PRAGMA_ONCE */
10 #if defined (ACE_HAS_THREADS)
12 #include "ace/Log_Category.h"
13 #if defined (ACE_HAS_ALLOC_HOOKS)
14 # include "ace/Malloc_Base.h"
15 #endif /* ACE_HAS_ALLOC_HOOKS */
17 #if !defined (__ACE_INLINE__)
18 #include "ace/Condition_T.inl"
19 #include "ace/Time_Value.h"
20 #endif /* __ACE_INLINE__ */
22 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
24 ACE_ALLOC_HOOK_DEFINE_Tc(ACE_Condition
)
25 ACE_ALLOC_HOOK_DEFINE_Tc(ACE_Thread_Condition
)
27 template <class MUTEX
> void
28 ACE_Condition
<MUTEX
>::dump () const
30 #if defined (ACE_HAS_DUMP)
31 // ACE_TRACE ("ACE_Condition<MUTEX>::dump");
33 ACELIB_DEBUG ((LM_DEBUG
, ACE_BEGIN_DUMP
, this));
34 ACELIB_DEBUG ((LM_DEBUG
, ACE_TEXT ("\n")));
35 ACELIB_DEBUG ((LM_DEBUG
, ACE_END_DUMP
));
36 #endif /* ACE_HAS_DUMP */
39 template <class MUTEX
>
40 ACE_Thread_Condition
<MUTEX
>::ACE_Thread_Condition (MUTEX
&m
,
41 const ACE_TCHAR
*name
,
43 : ACE_Condition
<MUTEX
> (m
, USYNC_THREAD
, name
, arg
)
45 // ACE_TRACE ("ACE_Thread_Condition<MUTEX>::ACE_Thread_Condition");
48 template <class MUTEX
> void
49 ACE_Thread_Condition
<MUTEX
>::dump () const
51 #if defined (ACE_HAS_DUMP)
52 // ACE_TRACE ("ACE_Thread_Condition<MUTEX>::dump");
54 ACE_Condition
<MUTEX
>::dump ();
55 #endif /* ACE_HAS_DUMP */
58 template <class MUTEX
>
59 ACE_Condition
<MUTEX
>::ACE_Condition (MUTEX
&m
,
61 const ACE_TCHAR
*name
,
66 // ACE_TRACE ("ACE_Condition<MUTEX>::ACE_Condition");
68 if (ACE_OS::cond_init (&this->cond_
,
72 ACELIB_ERROR ((LM_ERROR
,
74 ACE_TEXT ("ACE_Condition::ACE_Condition")));
77 template <class MUTEX
>
78 ACE_Condition
<MUTEX
>::ACE_Condition (MUTEX
&m
,
79 const ACE_Condition_Attributes
&attributes
,
80 const ACE_TCHAR
*name
,
84 // ACE_TRACE ("ACE_Condition<MUTEX>::ACE_Condition<MUTEX>");
85 if (ACE_OS::cond_init (&this->cond_
,
86 const_cast<ACE_condattr_t
&> (attributes
.attributes ()),
88 ACELIB_ERROR ((LM_ERROR
,
90 ACE_TEXT ("ACE_Condition::ACE_Condition")));
93 template <class MUTEX
>
94 ACE_Condition
<MUTEX
>::~ACE_Condition ()
96 // ACE_TRACE ("ACE_Condition<MUTEX>::~ACE_Condition");
98 if (this->remove () == -1)
99 ACELIB_ERROR ((LM_ERROR
,
101 ACE_TEXT ("ACE_Condition::~ACE_Condition")));
104 template <class MUTEX
> int
105 ACE_Condition
<MUTEX
>::wait ()
107 // ACE_TRACE ("ACE_Condition<MUTEX>::wait");
108 return ACE_OS::cond_wait (&this->cond_
,
109 &this->mutex_
.lock ());
112 template <class MUTEX
> int
113 ACE_Condition
<MUTEX
>::wait (MUTEX
&mutex
,
114 const ACE_Time_Value
*abstime
)
116 // ACE_TRACE ("ACE_Condition<MUTEX>::wait");
119 return ACE_OS::cond_wait (&this->cond_
,
124 ACE_Time_Value tv
= *abstime
;
125 return ACE_OS::cond_timedwait (&this->cond_
,
131 /// Peform an "alertable" timed wait. If @a abstime == 0
132 /// then we do a regular cond_wait(), else we do a timed wait for up to
134 template <class MUTEX
> int
135 ACE_Condition
<MUTEX
>::wait (const ACE_Time_Value
*abstime
)
137 // ACE_TRACE ("ACE_Condition<MUTEX>::wait");
138 return this->wait (this->mutex_
, abstime
);
141 ACE_END_VERSIONED_NAMESPACE_DECL
143 #endif /* ACE_HAS_THREADS */
145 #endif /* ACE_CONDITION_T_CPP */