1 //////////////////////////////////////////////////////////////////////////////
3 // (C) Copyright Ion Gaztanaga 2005-2012. Distributed under the Boost
4 // Software License, Version 1.0. (See accompanying file
5 // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
7 // See http://www.boost.org/libs/interprocess for documentation.
9 //////////////////////////////////////////////////////////////////////////////
11 #ifndef BOOST_INTERPROCESS_NULL_MUTEX_HPP
12 #define BOOST_INTERPROCESS_NULL_MUTEX_HPP
14 #ifndef BOOST_CONFIG_HPP
15 # include <boost/config.hpp>
18 #if defined(BOOST_HAS_PRAGMA_ONCE)
22 #include <boost/interprocess/detail/config_begin.hpp>
23 #include <boost/interprocess/detail/workaround.hpp>
27 //!Describes null_mutex classes
30 namespace interprocess {
32 //!Implements a mutex that simulates a mutex without doing any operation and
33 //!simulates a successful operation.
36 #if !defined(BOOST_INTERPROCESS_DOXYGEN_INVOKED)
37 null_mutex(const null_mutex&);
38 null_mutex &operator= (const null_mutex&);
39 #endif //#ifndef BOOST_INTERPROCESS_DOXYGEN_INVOKED
44 null_mutex() BOOST_NOEXCEPT {}
50 //!Simulates a mutex lock() operation. Empty function.
53 //!Simulates a mutex try_lock() operation.
54 //!Equivalent to "return true;"
58 //!Simulates a mutex timed_lock() operation.
59 //!Equivalent to "return true;"
60 template<class TimePoint>
61 bool timed_lock(const TimePoint &)
64 //!Same as `timed_lock`, but this function is modeled after the
65 //!standard library interface.
66 template<class TimePoint>
67 bool try_lock_until(const TimePoint &)
70 //!Same as `timed_lock`, but this function is modeled after the
71 //!standard library interface.
72 template<class Duration>
73 bool try_lock_for(const Duration &)
76 //!Simulates a mutex unlock() operation.
80 //!Simulates a mutex lock_sharable() operation.
82 void lock_sharable(){}
84 //!Same as `lock_sharable` but with a std-compatible interface
87 { this->lock_sharable(); }
89 //!Simulates a mutex try_lock_sharable() operation.
90 //!Equivalent to "return true;"
91 bool try_lock_sharable()
94 //!Same as `try_lock_sharable` but with a std-compatible interface
96 bool try_lock_shared()
97 { return this->try_lock_sharable(); }
99 //!Simulates a mutex timed_lock_sharable() operation.
100 //!Equivalent to "return true;"
101 template<class TimePoint>
102 bool timed_lock_sharable(const TimePoint &)
105 //!Simulates a mutex unlock_sharable() operation.
107 void unlock_sharable(){}
109 //!Same as `unlock_sharable` but with a std-compatible interface
112 { this->unlock_sharable(); }
114 //!Simulates a mutex lock_upgradable() operation.
116 void lock_upgradable(){}
118 //!Simulates a mutex try_lock_upgradable() operation.
119 //!Equivalent to "return true;"
120 bool try_lock_upgradable()
123 //!Simulates a mutex timed_lock_upgradable() operation.
124 //!Equivalent to "return true;"
125 template<class TimePoint>
126 bool timed_lock_upgradable(const TimePoint &)
129 //!Simulates a mutex unlock_upgradable() operation.
131 void unlock_upgradable(){}
133 //!Simulates unlock_and_lock_upgradable().
135 void unlock_and_lock_upgradable(){}
137 //!Simulates unlock_and_lock_sharable().
139 void unlock_and_lock_sharable(){}
141 //!Simulates unlock_upgradable_and_lock_sharable().
143 void unlock_upgradable_and_lock_sharable(){}
147 //!Simulates unlock_upgradable_and_lock().
149 void unlock_upgradable_and_lock(){}
151 //!Simulates try_unlock_upgradable_and_lock().
152 //!Equivalent to "return true;"
153 bool try_unlock_upgradable_and_lock()
156 //!Simulates timed_unlock_upgradable_and_lock().
157 //!Equivalent to "return true;"
158 template<class TimePoint>
159 bool timed_unlock_upgradable_and_lock(const TimePoint &)
162 //!Simulates try_unlock_sharable_and_lock().
163 //!Equivalent to "return true;"
164 bool try_unlock_sharable_and_lock()
167 //!Simulates try_unlock_sharable_and_lock_upgradable().
168 //!Equivalent to "return true;"
169 bool try_unlock_sharable_and_lock_upgradable()
173 } //namespace interprocess {
174 } //namespace boost {
176 #include <boost/interprocess/detail/config_end.hpp>
178 #endif //BOOST_INTERPROCESS_NULL_MUTEX_HPP