Merge pull request #2301 from sonndinh/remove-dup-reactor-functions
[ACE_TAO.git] / ACE / ace / Condition_Recursive_Thread_Mutex.h
blob5a6417841566e36a2086de38c93ac6b3aaf0db69
1 // -*- C++ -*-
3 //==========================================================================
4 /**
5 * @file Condition_Recursive_Thread_Mutex.h
7 * @author Douglas C. Schmidt <d.schmidt@vanderbilt.edu>
8 */
9 //==========================================================================
11 #ifndef ACE_CONDITION_RECURSIVE_THREAD_MUTEX_H
12 #define ACE_CONDITION_RECURSIVE_THREAD_MUTEX_H
13 #include /**/ "ace/pre.h"
15 #include /**/ "ace/ACE_export.h"
17 #if !defined (ACE_LACKS_PRAGMA_ONCE)
18 # pragma once
19 #endif /* ACE_LACKS_PRAGMA_ONCE */
21 #if !defined (ACE_HAS_THREADS)
22 # include "ace/Null_Condition.h"
23 #else /* ACE_HAS_THREADS */
24 #include "ace/Recursive_Thread_Mutex.h"
25 #include "ace/Condition_Attributes.h"
26 #include "ace/Condition_T.h"
28 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
30 /**
31 * @brief ACE_Condition template specialization written using
32 * @a ACE_Recursive_Thread_Mutex. This allows threads to block until
33 * shared data changes state using recursive mutexes.
35 template<>
36 class ACE_Export ACE_Condition<ACE_Recursive_Thread_Mutex>
38 public:
39 /// Initialize the condition variable with a recursive mutex.
40 ACE_Condition (ACE_Recursive_Thread_Mutex &m);
42 /// Initialize the condition variable.
43 ACE_Condition (ACE_Recursive_Thread_Mutex &m,
44 const ACE_Condition_Attributes &attributes);
46 /// Implicitly destroy the condition variable.
47 ~ACE_Condition ();
49 /**
50 * Explicitly destroy the condition variable. Note that only one
51 * thread should call this method since it doesn't protect against
52 * race conditions.
54 int remove ();
56 /**
57 * Block on condition, or until absolute time-of-day has passed. If
58 * abstime == 0 use "blocking" <wait> semantics. Else, if @a abstime
59 * != 0 and the call times out before the condition is signaled
60 * <wait> returns -1 and sets errno to ETIME.
62 int wait (const ACE_Time_Value *abstime = 0);
64 /**
65 * Block on condition or until absolute time-of-day has passed. If
66 * abstime == 0 use "blocking" wait() semantics on the recursive @a mutex
67 * passed as a parameter (this is useful if you need to store the
68 * <Condition> in shared memory). Else, if @a abstime != 0 and the
69 * call times out before the condition is signaled <wait> returns -1
70 * and sets errno to ETIME.
72 int wait (ACE_Recursive_Thread_Mutex &mutex,
73 const ACE_Time_Value *abstime = 0);
75 /// Signal one waiting thread.
76 int signal ();
78 /// Signal *all* waiting threads.
79 int broadcast ();
81 /// Returns a reference to the underlying mutex;
82 ACE_Recursive_Thread_Mutex &mutex ();
84 /// Dump the state of an object.
85 void dump () const;
87 private:
88 void operator= (const ACE_Condition<ACE_Recursive_Thread_Mutex> &) = delete;
89 ACE_Condition (const ACE_Condition<ACE_Recursive_Thread_Mutex> &) = delete;
91 private:
92 /// A normal (i.e., non-recursive) condition variable.
93 ACE_cond_t cond_;
95 /// Reference to the recursive mutex.
96 ACE_Recursive_Thread_Mutex &mutex_;
99 typedef ACE_Condition<ACE_Recursive_Thread_Mutex> ACE_Condition_Recursive_Thread_Mutex;
101 ACE_END_VERSIONED_NAMESPACE_DECL
103 #endif /* !ACE_HAS_THREADS */
105 #include /**/ "ace/post.h"
106 #endif /* ACE_CONDITION_RECURSIVE_THREAD_MUTEX_H */