Changes to attempt to silence bcc64x
[ACE_TAO.git] / ACE / ace / Condition_T.cpp
blob539bdf1232b9400bf151f6e20afc930c9e78b4b9
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)
7 # 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,
42 void *arg)
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,
60 int type,
61 const ACE_TCHAR *name,
62 void *arg)
64 mutex_ (m)
66 // ACE_TRACE ("ACE_Condition<MUTEX>::ACE_Condition");
68 if (ACE_OS::cond_init (&this->cond_,
69 (short) type,
70 name,
71 arg) != 0)
72 ACELIB_ERROR ((LM_ERROR,
73 ACE_TEXT ("%p\n"),
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,
81 void *arg)
82 : mutex_ (m)
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 ()),
87 name, arg) != 0)
88 ACELIB_ERROR ((LM_ERROR,
89 ACE_TEXT ("%p\n"),
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,
100 ACE_TEXT ("%p\n"),
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");
117 if (abstime == 0)
119 return ACE_OS::cond_wait (&this->cond_,
120 &mutex.lock ());
122 else
124 ACE_Time_Value tv = *abstime;
125 return ACE_OS::cond_timedwait (&this->cond_,
126 &mutex.lock (),
127 &tv);
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
133 /// @a abstime
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 */