Mercurial > hg > vamp-build-and-test
comparison DEPENDENCIES/generic/include/boost/interprocess/sync/detail/locks.hpp @ 16:2665513ce2d3
Add boost headers
author | Chris Cannam |
---|---|
date | Tue, 05 Aug 2014 11:11:38 +0100 |
parents | |
children | c530137014c0 |
comparison
equal
deleted
inserted
replaced
15:663ca0da4350 | 16:2665513ce2d3 |
---|---|
1 ////////////////////////////////////////////////////////////////////////////// | |
2 // | |
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) | |
6 // | |
7 // See http://www.boost.org/libs/interprocess for documentation. | |
8 // | |
9 ////////////////////////////////////////////////////////////////////////////// | |
10 | |
11 #ifndef BOOST_INTERPROCESS_DETAIL_LOCKS_HPP | |
12 #define BOOST_INTERPROCESS_DETAIL_LOCKS_HPP | |
13 | |
14 #include <boost/interprocess/detail/config_begin.hpp> | |
15 #include <boost/interprocess/detail/workaround.hpp> | |
16 | |
17 namespace boost { | |
18 namespace interprocess { | |
19 namespace ipcdetail { | |
20 | |
21 template<class Lock> | |
22 class internal_mutex_lock | |
23 { | |
24 typedef void (internal_mutex_lock::*unspecified_bool_type)(); | |
25 public: | |
26 | |
27 typedef typename Lock::mutex_type::internal_mutex_type mutex_type; | |
28 | |
29 | |
30 internal_mutex_lock(Lock &l) | |
31 : l_(l) | |
32 {} | |
33 | |
34 mutex_type* mutex() const | |
35 { return l_ ? &l_.mutex()->internal_mutex() : 0; } | |
36 | |
37 void lock() { l_.lock(); } | |
38 | |
39 void unlock() { l_.unlock(); } | |
40 | |
41 operator unspecified_bool_type() const | |
42 { return l_ ? &internal_mutex_lock::lock : 0; } | |
43 | |
44 private: | |
45 Lock &l_; | |
46 }; | |
47 | |
48 template <class Lock> | |
49 class lock_inverter | |
50 { | |
51 Lock &l_; | |
52 public: | |
53 lock_inverter(Lock &l) | |
54 : l_(l) | |
55 {} | |
56 void lock() { l_.unlock(); } | |
57 void unlock() { l_.lock(); } | |
58 }; | |
59 | |
60 } //namespace ipcdetail | |
61 } //namespace interprocess | |
62 } //namespace boost | |
63 | |
64 #include <boost/interprocess/detail/config_end.hpp> | |
65 | |
66 #endif //BOOST_INTERPROCESS_DETAIL_LOCKS_HPP |