Mercurial > hg > vamp-build-and-test
annotate DEPENDENCIES/generic/include/boost/thread/reverse_lock.hpp @ 125:34e428693f5d vext
Vext -> Repoint
author | Chris Cannam |
---|---|
date | Thu, 14 Jun 2018 11:15:39 +0100 |
parents | 2665513ce2d3 |
children |
rev | line source |
---|---|
Chris@16 | 1 // Distributed under the Boost Software License, Version 1.0. (See |
Chris@16 | 2 // accompanying file LICENSE_1_0.txt or copy at |
Chris@16 | 3 // http://www.boost.org/LICENSE_1_0.txt) |
Chris@16 | 4 // (C) Copyright 2012 Vicente J. Botet Escriba |
Chris@16 | 5 |
Chris@16 | 6 #ifndef BOOST_THREAD_REVERSE_LOCK_HPP |
Chris@16 | 7 #define BOOST_THREAD_REVERSE_LOCK_HPP |
Chris@16 | 8 #include <boost/thread/detail/config.hpp> |
Chris@16 | 9 #include <boost/thread/detail/move.hpp> |
Chris@16 | 10 #include <boost/thread/lockable_traits.hpp> |
Chris@16 | 11 #include <boost/thread/lock_options.hpp> |
Chris@16 | 12 #include <boost/thread/detail/delete.hpp> |
Chris@16 | 13 |
Chris@16 | 14 namespace boost |
Chris@16 | 15 { |
Chris@16 | 16 |
Chris@16 | 17 template<typename Lock> |
Chris@16 | 18 class reverse_lock |
Chris@16 | 19 { |
Chris@16 | 20 public: |
Chris@16 | 21 typedef typename Lock::mutex_type mutex_type; |
Chris@16 | 22 BOOST_THREAD_NO_COPYABLE(reverse_lock) |
Chris@16 | 23 |
Chris@16 | 24 explicit reverse_lock(Lock& m_) |
Chris@16 | 25 : m(m_), mtx(0) |
Chris@16 | 26 { |
Chris@16 | 27 if (m.owns_lock()) |
Chris@16 | 28 { |
Chris@16 | 29 m.unlock(); |
Chris@16 | 30 } |
Chris@16 | 31 mtx=m.release(); |
Chris@16 | 32 } |
Chris@16 | 33 ~reverse_lock() |
Chris@16 | 34 { |
Chris@16 | 35 if (mtx) { |
Chris@16 | 36 mtx->lock(); |
Chris@16 | 37 m = BOOST_THREAD_MAKE_RV_REF(Lock(*mtx, adopt_lock)); |
Chris@16 | 38 } |
Chris@16 | 39 } |
Chris@16 | 40 |
Chris@16 | 41 private: |
Chris@16 | 42 Lock& m; |
Chris@16 | 43 mutex_type* mtx; |
Chris@16 | 44 }; |
Chris@16 | 45 |
Chris@16 | 46 |
Chris@16 | 47 #ifdef BOOST_THREAD_NO_AUTO_DETECT_MUTEX_TYPES |
Chris@16 | 48 template<typename T> |
Chris@16 | 49 struct is_mutex_type<reverse_lock<T> > |
Chris@16 | 50 { |
Chris@16 | 51 BOOST_STATIC_CONSTANT(bool, value = true); |
Chris@16 | 52 }; |
Chris@16 | 53 |
Chris@16 | 54 #endif |
Chris@16 | 55 |
Chris@16 | 56 |
Chris@16 | 57 } |
Chris@16 | 58 |
Chris@16 | 59 #endif // header |