Document return values
[ACE_TAO.git] / ACE / ace / Condition_Thread_Mutex.cpp
blob59a8a7f4de6e5bd55dc7c90457df1a5c250ae442
1 /* -*- C++ -*- */
2 /**
3 * @file Condition_Thread_Mutex.cpp
5 * @author Douglas C. Schmidt <d.schmidt@vanderbilt.edu>
6 */
8 #include "ace/Condition_Thread_Mutex.h"
10 #if defined (ACE_HAS_THREADS)
12 #if !defined (__ACE_INLINE__)
13 #include "ace/Condition_Thread_Mutex.inl"
14 #endif /* __ACE_INLINE__ */
16 #include "ace/Log_Category.h"
18 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
20 ACE_ALLOC_HOOK_DEFINE(ACE_Condition<ACE_Thread_Mutex>)
22 void
23 ACE_Condition<ACE_Thread_Mutex>::dump () const
25 #if defined (ACE_HAS_DUMP)
26 // ACE_TRACE ("ACE_Condition<ACE_Thread_Mutex>::dump");
28 ACELIB_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
29 ACELIB_DEBUG ((LM_DEBUG, ACE_TEXT ("\n")));
30 #if defined (ACE_WIN32)
31 ACELIB_DEBUG ((LM_DEBUG,
32 ACE_TEXT ("waiters = %d\n"),
33 this->cond_.waiters ()));
34 #endif /* ACE_WIN32 */
35 ACELIB_DEBUG ((LM_DEBUG, ACE_END_DUMP));
36 #endif /* ACE_HAS_DUMP */
39 ACE_Condition<ACE_Thread_Mutex>::ACE_Condition (ACE_Thread_Mutex &m,
40 const ACE_TCHAR *name,
41 void *arg)
42 : mutex_ (m),
43 removed_ (false)
45 // ACE_TRACE ("ACE_Condition<ACE_Thread_Mutex>::ACE_Condition<ACE_Thread_Mutex>");
46 if (ACE_OS::cond_init (&this->cond_,
47 (short) USYNC_THREAD,
48 name,
49 arg) != 0)
50 ACELIB_ERROR ((LM_ERROR,
51 ACE_TEXT ("%p\n"),
52 ACE_TEXT ("ACE_Condition<ACE_Thread_Mutex>::ACE_Condition<ACE_Thread_Mutex>")));
55 ACE_Condition<ACE_Thread_Mutex>::ACE_Condition (ACE_Thread_Mutex &m,
56 const ACE_Condition_Attributes &attributes,
57 const ACE_TCHAR *name,
58 void *arg)
59 : mutex_ (m),
60 removed_ (false)
62 // ACE_TRACE ("ACE_Condition<ACE_Thread_Mutex>::ACE_Condition<ACE_Thread_Mutex>");
63 if (ACE_OS::cond_init (&this->cond_,
64 const_cast<ACE_condattr_t &> (attributes.attributes ()),
65 name, arg) != 0)
66 ACELIB_ERROR ((LM_ERROR, ACE_TEXT ("%p\n"),
67 ACE_TEXT ("ACE_Condition<ACE_Thread_Mutex>::ACE_Condition<ACE_Thread_Mutex>")));
70 ACE_Condition<ACE_Thread_Mutex>::~ACE_Condition ()
72 // ACE_TRACE ("ACE_Condition<ACE_Thread_Mutex>::~ACE_Condition<ACE_Thread_Mutex>");
73 this->remove ();
76 // Peform an "alertable" timed wait. If the argument <abstime> == 0
77 // then we do a regular <cond_wait>, else we do a timed wait for up to
78 // <abstime> using the <cond_timedwait> function.
80 int
81 ACE_Condition<ACE_Thread_Mutex>::wait ()
83 // ACE_TRACE ("ACE_Condition<ACE_Thread_Mutex>::wait");
84 return ACE_OS::cond_wait (&this->cond_, &this->mutex_.lock ());
87 int
88 ACE_Condition<ACE_Thread_Mutex>::wait (ACE_Thread_Mutex &mutex,
89 const ACE_Time_Value *abstime)
91 // ACE_TRACE ("ACE_Condition<ACE_Thread_Mutex>::wait");
92 return ACE_OS::cond_timedwait (&this->cond_,
93 &mutex.lock (),
94 const_cast <ACE_Time_Value *> (abstime));
97 int
98 ACE_Condition<ACE_Thread_Mutex>::wait (const ACE_Time_Value *abstime)
100 // ACE_TRACE ("ACE_Condition<ACE_Thread_Mutex>::wait");
101 return this->wait (this->mutex_, abstime);
105 ACE_Condition<ACE_Thread_Mutex>::signal ()
107 // ACE_TRACE ("ACE_Condition<ACE_Thread_Mutex>::signal");
108 return ACE_OS::cond_signal (&this->cond_);
112 ACE_Condition<ACE_Thread_Mutex>::broadcast ()
114 // ACE_TRACE ("ACE_Condition<ACE_Thread_Mutex>::broadcast");
115 return ACE_OS::cond_broadcast (&this->cond_);
118 ACE_END_VERSIONED_NAMESPACE_DECL
120 #endif /* ACE_HAS_THREADS */