3 //==========================================================================
7 * @author Douglas C. Schmidt <d.schmidt@vanderbilt.edu>
9 //==========================================================================
11 #ifndef ACE_NULL_MUTEX_H
12 #define ACE_NULL_MUTEX_H
13 #include /**/ "ace/pre.h"
15 #include "ace/os_include/os_errno.h"
17 #if !defined (ACE_LACKS_PRAGMA_ONCE)
19 #endif /* ACE_LACKS_PRAGMA_ONCE */
21 #include "ace/Global_Macros.h"
22 #include "ace/OS_Memory.h"
24 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
29 * @class ACE_Null_Mutex
31 * @brief Implement a do nothing ACE_Mutex, i.e., all the methods are
34 class ACE_Export ACE_Null_Mutex
37 ACE_Null_Mutex (const ACE_TCHAR
* = 0)
39 ~ACE_Null_Mutex () = default;
41 int remove () {return 0;}
44 int acquire () {return 0;}
46 /// Return -1 with @c errno == @c ETIME.
47 int acquire (ACE_Time_Value
&) {errno
= ETIME
; return -1;}
49 /// Return -1 with @c errno == @c ETIME.
50 int acquire (ACE_Time_Value
*) {errno
= ETIME
; return -1;}
53 int tryacquire () {return 0;}
56 int release () {return 0;}
59 int acquire_write () {return 0;}
62 int tryacquire_write () {return 0;}
65 int tryacquire_write_upgrade () {return 0;}
68 int acquire_read () {return 0;}
71 int tryacquire_read () {return 0;}
73 /// Dump the state of an object.
76 /// Declare the dynamic allocation hooks.
77 //ACE_ALLOC_HOOK_DECLARE;
79 int lock_
; // A dummy lock.
81 ACE_ALLOC_HOOK_DECLARE
;
84 // FUZZ: disable check_for_ACE_Guard
86 template <class ACE_LOCK
>
90 * @brief Template specialization of ACE_Guard for the
93 * This specialization is useful since it helps to speedup
94 * performance of the "Null_Mutex" considerably.
97 class ACE_Export ACE_Guard
<ACE_Null_Mutex
>
100 ACE_Guard (ACE_Null_Mutex
&) {}
101 ACE_Guard (ACE_Null_Mutex
&, int) {}
102 ACE_Guard (ACE_Null_Mutex
&, int, int) {}
103 #if defined (ACE_WIN32)
104 ~ACE_Guard () = default;
105 #endif /* ACE_WIN32 */
107 int acquire () { return 0; }
108 int tryacquire () { return 0; }
109 int release () { return 0; }
111 int locked () { return 1; }
112 int remove () { return 0; }
113 void dump () const {}
116 ACE_Guard (const ACE_Guard
<ACE_Null_Mutex
> &) = delete;
117 void operator= (const ACE_Guard
<ACE_Null_Mutex
> &) = delete;
118 ACE_Guard (ACE_Guard
<ACE_Null_Mutex
> &&) = delete;
119 void operator= (ACE_Guard
<ACE_Null_Mutex
> &&) = delete;
122 template <class ACE_LOCK
>
123 class ACE_Write_Guard
;
126 * @brief Template specialization of ACE_Write_Guard for the
130 class ACE_Export ACE_Write_Guard
<ACE_Null_Mutex
>
131 : public ACE_Guard
<ACE_Null_Mutex
>
134 ACE_Write_Guard (ACE_Null_Mutex
&m
)
135 : ACE_Guard
<ACE_Null_Mutex
> (m
) {}
136 ACE_Write_Guard (ACE_Null_Mutex
&m
, int blocked
)
137 : ACE_Guard
<ACE_Null_Mutex
> (m
, blocked
) {}
139 int acquire_write () { return 0; }
140 int acquire () { return 0; }
141 int tryacquire_write () { return 0; }
142 int tryacquire () { return 0; }
143 void dump () const {}
146 template <class ACE_LOCK
>
147 class ACE_Read_Guard
;
150 * @brief Template specialization of ACE_Read)Guard for the
154 class ACE_Export ACE_Read_Guard
<ACE_Null_Mutex
>
155 : public ACE_Guard
<ACE_Null_Mutex
>
158 ACE_Read_Guard (ACE_Null_Mutex
&m
)
159 : ACE_Guard
<ACE_Null_Mutex
> (m
) {}
160 ACE_Read_Guard (ACE_Null_Mutex
&m
, int blocked
)
161 : ACE_Guard
<ACE_Null_Mutex
> (m
, blocked
) {}
163 int acquire_read () { return 0; }
164 int acquire () { return 0; }
165 int tryacquire_read () { return 0; }
166 int tryacquire () { return 0; }
167 void dump () const {}
170 // FUZZ: enable check_for_ACE_Guard
172 template <class T
> class ACE_Malloc_Lock_Adapter_T
;
175 * @brief Template specialization of ACE_Malloc_Lock_Adapter_T for the
179 class ACE_Export ACE_Malloc_Lock_Adapter_T
<ACE_Null_Mutex
>
182 ACE_Null_Mutex
* operator () (const ACE_TCHAR
*name
)
185 ACE_NEW_RETURN (p
, ACE_Null_Mutex (name
), 0);
190 ACE_END_VERSIONED_NAMESPACE_DECL
192 #include /**/ "ace/post.h"
193 #endif /* ACE_NULL_MUTEX_H */