1 //////////////////////////////////////////////////////////////////////////////
2 //
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)
6 //
7 // See http://www.boost.org/libs/interprocess for documentation.
8 //
9 //////////////////////////////////////////////////////////////////////////////
10 
11 #ifndef BOOST_INTERPROCESS_NULL_MUTEX_HPP
12 #define BOOST_INTERPROCESS_NULL_MUTEX_HPP
13 
14 #ifndef BOOST_CONFIG_HPP
15 #  include <boost/config.hpp>
16 #endif
17 #
18 #if defined(BOOST_HAS_PRAGMA_ONCE)
19 #  pragma once
20 #endif
21 
22 #include <boost/interprocess/detail/config_begin.hpp>
23 #include <boost/interprocess/detail/workaround.hpp>
24 
25 
26 //!\file
27 //!Describes null_mutex classes
28 
29 namespace boost {
30 namespace interprocess {
31 
32 //!Implements a mutex that simulates a mutex without doing any operation and
33 //!simulates a successful operation.
34 class null_mutex
35 {
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
40    public:
41 
42    //!Constructor.
43    //!Empty.
null_mutex()44    null_mutex() BOOST_NOEXCEPT {}
45 
46    //!Destructor.
47    //!Empty.
~null_mutex()48    ~null_mutex(){}
49 
50    //!Simulates a mutex lock() operation. Empty function.
lock()51    void lock(){}
52 
53    //!Simulates a mutex try_lock() operation.
54    //!Equivalent to "return true;"
try_lock()55    bool try_lock()
56    {  return true;   }
57 
58    //!Simulates a mutex timed_lock() operation.
59    //!Equivalent to "return true;"
60    template<class TimePoint>
timed_lock(const TimePoint &)61    bool timed_lock(const TimePoint &)
62    {  return true;   }
63 
64    //!Same as `timed_lock`, but this function is modeled after the
65    //!standard library interface.
66    template<class TimePoint>
try_lock_until(const TimePoint &)67    bool try_lock_until(const TimePoint &)
68    {  return true;  }
69 
70    //!Same as `timed_lock`, but this function is modeled after the
71    //!standard library interface.
72    template<class Duration>
try_lock_for(const Duration &)73    bool try_lock_for(const Duration &)
74    {  return true; }
75 
76    //!Simulates a mutex unlock() operation.
77    //!Empty function.
unlock()78    void unlock(){}
79 
80    //!Simulates a mutex lock_sharable() operation.
81    //!Empty function.
lock_sharable()82    void lock_sharable(){}
83 
84    //!Same as `lock_sharable` but with a std-compatible interface
85    //!
lock_shared()86    void lock_shared()
87    {  this->lock_sharable();  }
88 
89    //!Simulates a mutex try_lock_sharable() operation.
90    //!Equivalent to "return true;"
try_lock_sharable()91    bool try_lock_sharable()
92    {  return true;   }
93 
94    //!Same as `try_lock_sharable` but with a std-compatible interface
95    //!
try_lock_shared()96    bool try_lock_shared()
97    {  return this->try_lock_sharable();  }
98 
99    //!Simulates a mutex timed_lock_sharable() operation.
100    //!Equivalent to "return true;"
101    template<class TimePoint>
timed_lock_sharable(const TimePoint &)102    bool timed_lock_sharable(const TimePoint &)
103    {  return true;   }
104 
105    //!Simulates a mutex unlock_sharable() operation.
106    //!Empty function.
unlock_sharable()107    void unlock_sharable(){}
108 
109    //!Same as `unlock_sharable` but with a std-compatible interface
110    //!
unlock_shared()111    void unlock_shared()
112    {  this->unlock_sharable();  }
113 
114    //!Simulates a mutex lock_upgradable() operation.
115    //!Empty function.
lock_upgradable()116    void lock_upgradable(){}
117 
118    //!Simulates a mutex try_lock_upgradable() operation.
119    //!Equivalent to "return true;"
try_lock_upgradable()120    bool try_lock_upgradable()
121    {  return true;   }
122 
123    //!Simulates a mutex timed_lock_upgradable() operation.
124    //!Equivalent to "return true;"
125    template<class TimePoint>
timed_lock_upgradable(const TimePoint &)126    bool timed_lock_upgradable(const TimePoint &)
127    {  return true;   }
128 
129    //!Simulates a mutex unlock_upgradable() operation.
130    //!Empty function.
unlock_upgradable()131    void unlock_upgradable(){}
132 
133    //!Simulates unlock_and_lock_upgradable().
134    //!Empty function.
unlock_and_lock_upgradable()135    void unlock_and_lock_upgradable(){}
136 
137    //!Simulates unlock_and_lock_sharable().
138    //!Empty function.
unlock_and_lock_sharable()139    void unlock_and_lock_sharable(){}
140 
141    //!Simulates unlock_upgradable_and_lock_sharable().
142    //!Empty function.
unlock_upgradable_and_lock_sharable()143    void unlock_upgradable_and_lock_sharable(){}
144 
145    //Promotions
146 
147    //!Simulates unlock_upgradable_and_lock().
148    //!Empty function.
unlock_upgradable_and_lock()149    void unlock_upgradable_and_lock(){}
150 
151    //!Simulates try_unlock_upgradable_and_lock().
152    //!Equivalent to "return true;"
try_unlock_upgradable_and_lock()153    bool try_unlock_upgradable_and_lock()
154    {  return true;   }
155 
156    //!Simulates timed_unlock_upgradable_and_lock().
157    //!Equivalent to "return true;"
158    template<class TimePoint>
timed_unlock_upgradable_and_lock(const TimePoint &)159    bool timed_unlock_upgradable_and_lock(const TimePoint &)
160    {  return true;   }
161 
162    //!Simulates try_unlock_sharable_and_lock().
163    //!Equivalent to "return true;"
try_unlock_sharable_and_lock()164    bool try_unlock_sharable_and_lock()
165    {  return true;   }
166 
167    //!Simulates try_unlock_sharable_and_lock_upgradable().
168    //!Equivalent to "return true;"
try_unlock_sharable_and_lock_upgradable()169    bool try_unlock_sharable_and_lock_upgradable()
170    {  return true;   }
171 };
172 
173 }  //namespace interprocess {
174 }  //namespace boost {
175 
176 #include <boost/interprocess/detail/config_end.hpp>
177 
178 #endif   //BOOST_INTERPROCESS_NULL_MUTEX_HPP
179