Chris@16: ////////////////////////////////////////////////////////////////////////////// Chris@16: // Chris@16: // (C) Copyright Ion Gaztanaga 2012-2012. Distributed under the Boost Chris@16: // Software License, Version 1.0. (See accompanying file Chris@16: // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) Chris@16: // Chris@16: // See http://www.boost.org/libs/interprocess for documentation. Chris@16: // Chris@16: ////////////////////////////////////////////////////////////////////////////// Chris@16: Chris@16: #ifndef BOOST_INTERPROCESS_DETAIL_LOCKS_HPP Chris@16: #define BOOST_INTERPROCESS_DETAIL_LOCKS_HPP Chris@16: Chris@16: #include Chris@16: #include Chris@16: Chris@16: namespace boost { Chris@16: namespace interprocess { Chris@16: namespace ipcdetail { Chris@16: Chris@16: template Chris@16: class internal_mutex_lock Chris@16: { Chris@16: typedef void (internal_mutex_lock::*unspecified_bool_type)(); Chris@16: public: Chris@16: Chris@16: typedef typename Lock::mutex_type::internal_mutex_type mutex_type; Chris@16: Chris@16: Chris@16: internal_mutex_lock(Lock &l) Chris@16: : l_(l) Chris@16: {} Chris@16: Chris@16: mutex_type* mutex() const Chris@16: { return l_ ? &l_.mutex()->internal_mutex() : 0; } Chris@16: Chris@16: void lock() { l_.lock(); } Chris@16: Chris@16: void unlock() { l_.unlock(); } Chris@16: Chris@16: operator unspecified_bool_type() const Chris@16: { return l_ ? &internal_mutex_lock::lock : 0; } Chris@16: Chris@16: private: Chris@16: Lock &l_; Chris@16: }; Chris@16: Chris@16: template Chris@16: class lock_inverter Chris@16: { Chris@16: Lock &l_; Chris@16: public: Chris@16: lock_inverter(Lock &l) Chris@16: : l_(l) Chris@16: {} Chris@16: void lock() { l_.unlock(); } Chris@16: void unlock() { l_.lock(); } Chris@16: }; Chris@16: Chris@16: } //namespace ipcdetail Chris@16: } //namespace interprocess Chris@16: } //namespace boost Chris@16: Chris@16: #include Chris@16: Chris@16: #endif //BOOST_INTERPROCESS_DETAIL_LOCKS_HPP