Line data Source code
1 : /* 2 : Provides a basic subset of boost::unique_lock functionality. Provided only because 3 : including boost/thread/locks.hpp requires linking to thread library 4 : */ 5 : // Copyright Frank Mori Hess 2008. 6 : // Distributed under the Boost Software License, Version 7 : // 1.0. (See accompanying file LICENSE_1_0.txt or copy at 8 : // http://www.boost.org/LICENSE_1_0.txt) 9 : 10 : // See http://www.boost.org/libs/signals2 for library home page. 11 : 12 : #ifndef BOOST_SIGNALS2_UNIQUE_LOCK_HPP 13 : #define BOOST_SIGNALS2_UNIQUE_LOCK_HPP 14 : 15 : #include <boost/core/noncopyable.hpp> 16 : 17 : namespace boost 18 : { 19 : namespace signals2 20 : { 21 : namespace detail 22 : { 23 : template<typename Mutex> 24 : class unique_lock: public noncopyable 25 : { 26 : public: 27 3558404 : unique_lock(Mutex &m): _mutex(m) 28 1779202 : { 29 1779202 : _mutex.lock(); 30 3558404 : } 31 3558404 : ~unique_lock() 32 1779202 : { 33 1779202 : _mutex.unlock(); 34 3558404 : } 35 : private: 36 : Mutex &_mutex; 37 : }; 38 : } // namespace detail 39 : } // namespace signals2 40 : } // namespace boost 41 : 42 : #endif // BOOST_SIGNALS2_UNIQUE_LOCK_HPP