1 //////////////////////////////////////////////////////////////////////////////
3 // (C) Copyright Ion Gaztanaga 2012-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_DETAIL_LOCKS_HPP
12 #define BOOST_INTERPROCESS_DETAIL_LOCKS_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>
26 namespace interprocess {
30 class internal_mutex_lock
32 typedef void (internal_mutex_lock::*unspecified_bool_type)();
35 typedef typename Lock::mutex_type::internal_mutex_type mutex_type;
38 internal_mutex_lock(Lock &l)
42 mutex_type* mutex() const
43 { return l_ ? &l_.mutex()->internal_mutex() : 0; }
45 void lock() { l_.lock(); }
47 void unlock() { l_.unlock(); }
49 operator unspecified_bool_type() const
50 { return l_ ? &internal_mutex_lock::lock : 0; }
61 lock_inverter(Lock &l)
64 void lock() { l_.unlock(); }
65 void unlock() { l_.lock(); }
69 class lock_to_sharable
74 explicit lock_to_sharable(Lock &l)
77 void lock() { l_.lock_sharable(); }
78 bool try_lock(){ return l_.try_lock_sharable(); }
79 void unlock() { l_.unlock_sharable(); }
88 explicit lock_to_wait(Lock &l)
91 void lock() { l_.wait(); }
92 bool try_lock(){ return l_.try_wait(); }
95 } //namespace ipcdetail
96 } //namespace interprocess
99 #include <boost/interprocess/detail/config_end.hpp>
101 #endif //BOOST_INTERPROCESS_DETAIL_LOCKS_HPP