Changes to attempt to silence bcc64x
[ACE_TAO.git] / ACE / ace / Null_Mutex.h
blob86999a0f18cf14bdd98f779fc7fb89ce0d6e4e32
1 // -*- C++ -*-
3 //==========================================================================
4 /**
5 * @file Null_Mutex.h
7 * @author Douglas C. Schmidt <d.schmidt@vanderbilt.edu>
8 */
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)
18 # 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
26 class ACE_Time_Value;
28 /**
29 * @class ACE_Null_Mutex
31 * @brief Implement a do nothing ACE_Mutex, i.e., all the methods are
32 * no ops.
34 class ACE_Export ACE_Null_Mutex
36 public:
37 ACE_Null_Mutex (const ACE_TCHAR * = 0)
38 : lock_ (0) {}
39 ~ACE_Null_Mutex () = default;
40 /// Return 0.
41 int remove () {return 0;}
43 /// 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;}
52 /// Return 0.
53 int tryacquire () {return 0;}
55 /// Return 0.
56 int release () {return 0;}
58 /// Return 0.
59 int acquire_write () {return 0;}
61 /// Return 0.
62 int tryacquire_write () {return 0;}
64 /// Return 0.
65 int tryacquire_write_upgrade () {return 0;}
67 /// Return 0.
68 int acquire_read () {return 0;}
70 /// Return 0.
71 int tryacquire_read () {return 0;}
73 /// Dump the state of an object.
74 void dump () const {}
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>
87 class ACE_Guard;
89 /**
90 * @brief Template specialization of ACE_Guard for the
91 * ACE_Null_Mutex.
93 * This specialization is useful since it helps to speedup
94 * performance of the "Null_Mutex" considerably.
96 template<>
97 class ACE_Export ACE_Guard<ACE_Null_Mutex>
99 public:
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; }
110 void disown () {}
111 int locked () { return 1; }
112 int remove () { return 0; }
113 void dump () const {}
115 private:
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
127 * ACE_Null_Mutex.
129 template<>
130 class ACE_Export ACE_Write_Guard<ACE_Null_Mutex>
131 : public ACE_Guard<ACE_Null_Mutex>
133 public:
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
151 * ACE_Null_Mutex.
153 template<>
154 class ACE_Export ACE_Read_Guard<ACE_Null_Mutex>
155 : public ACE_Guard<ACE_Null_Mutex>
157 public:
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
176 * ACE_Null_Mutex.
178 template<>
179 class ACE_Export ACE_Malloc_Lock_Adapter_T<ACE_Null_Mutex>
181 public:
182 ACE_Null_Mutex * operator () (const ACE_TCHAR *name)
184 ACE_Null_Mutex *p;
185 ACE_NEW_RETURN (p, ACE_Null_Mutex (name), 0);
186 return p;
190 ACE_END_VERSIONED_NAMESPACE_DECL
192 #include /**/ "ace/post.h"
193 #endif /* ACE_NULL_MUTEX_H */