]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/thread/include/boost/thread/concurrent_queues/deque_adaptor.hpp
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / thread / include / boost / thread / concurrent_queues / deque_adaptor.hpp
1 #ifndef BOOST_THREAD_CONCURRENT_DEQUE_ADAPTOR_HPP
2 #define BOOST_THREAD_CONCURRENT_DEQUE_ADAPTOR_HPP
3
4 //////////////////////////////////////////////////////////////////////////////
5 //
6 // (C) Copyright Vicente J. Botet Escriba 2014. Distributed under the Boost
7 // Software License, Version 1.0. (See accompanying file
8 // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9 //
10 // See http://www.boost.org/libs/thread for documentation.
11 //
12 //////////////////////////////////////////////////////////////////////////////
13
14 #include <boost/thread/detail/config.hpp>
15 #include <boost/thread/detail/move.hpp>
16 #include <boost/thread/concurrent_queues/queue_op_status.hpp>
17 #include <boost/thread/concurrent_queues/deque_base.hpp>
18
19 #include <boost/config/abi_prefix.hpp>
20
21 namespace boost
22 {
23 namespace concurrent
24 {
25 namespace detail
26 {
27
28 template <typename Queue>
29 class deque_adaptor_copyable_only :
30 public boost::deque_base<typename Queue::value_type, typename Queue::size_type>
31 {
32 Queue queue;
33 public:
34 typedef typename Queue::value_type value_type;
35 typedef typename Queue::size_type size_type;
36
37 // Constructors/Assignment/Destructors
38 deque_adaptor_copyable_only() {}
39
40 // Observers
41 bool empty() const { return queue.empty(); }
42 bool full() const { return queue.full(); }
43 size_type size() const { return queue.size(); }
44 bool closed() const { return queue.closed(); }
45
46 // Modifiers
47 void close() { queue.close(); }
48
49 void push_back(const value_type& x) { queue.push_back(x); }
50
51 void pull_front(value_type& x) { queue.pull_front(x); };
52 value_type pull_front() { return queue.pull_front(); }
53
54 queue_op_status try_push_back(const value_type& x) { return queue.try_push_back(x); }
55 queue_op_status try_pull_front(value_type& x) { return queue.try_pull_front(x); }
56
57 queue_op_status nonblocking_push_back(const value_type& x) { return queue.nonblocking_push_back(x); }
58 queue_op_status nonblocking_pull_front(value_type& x) { return queue.nonblocking_pull_front(x); }
59
60 queue_op_status wait_push_back(const value_type& x) { return queue.wait_push_back(x); }
61 queue_op_status wait_pull_front(value_type& x) { return queue.wait_pull_front(x); }
62
63 };
64 template <typename Queue>
65 class deque_adaptor_movable_only :
66 public boost::deque_base<typename Queue::value_type, typename Queue::size_type>
67 {
68 Queue queue;
69 public:
70 typedef typename Queue::value_type value_type;
71 typedef typename Queue::size_type size_type;
72
73 // Constructors/Assignment/Destructors
74
75 deque_adaptor_movable_only() {}
76
77 // Observers
78 bool empty() const { return queue.empty(); }
79 bool full() const { return queue.full(); }
80 size_type size() const { return queue.size(); }
81 bool closed() const { return queue.closed(); }
82
83 // Modifiers
84 void close() { queue.close(); }
85
86
87 void pull_front(value_type& x) { queue.pull_front(x); };
88 // enable_if is_nothrow_copy_movable<value_type>
89 value_type pull_front() { return queue.pull_front(); }
90
91 queue_op_status try_pull_front(value_type& x) { return queue.try_pull_front(x); }
92
93 queue_op_status nonblocking_pull_front(value_type& x) { return queue.nonblocking_pull_front(x); }
94
95 queue_op_status wait_pull_front(value_type& x) { return queue.wait_pull_front(x); }
96
97 void push_back(BOOST_THREAD_RV_REF(value_type) x) { queue.push_back(boost::move(x)); }
98 queue_op_status try_push_back(BOOST_THREAD_RV_REF(value_type) x) { return queue.try_push_back(boost::move(x)); }
99 queue_op_status nonblocking_push_back(BOOST_THREAD_RV_REF(value_type) x) { return queue.nonblocking_push_back(boost::move(x)); }
100 queue_op_status wait_push_back(BOOST_THREAD_RV_REF(value_type) x) { return queue.wait_push_back(boost::move(x)); }
101 };
102
103 template <typename Queue>
104 class deque_adaptor_copyable_and_movable :
105 public boost::deque_base<typename Queue::value_type, typename Queue::size_type>
106 {
107 Queue queue;
108 public:
109 typedef typename Queue::value_type value_type;
110 typedef typename Queue::size_type size_type;
111
112 // Constructors/Assignment/Destructors
113
114 deque_adaptor_copyable_and_movable() {}
115
116 // Observers
117 bool empty() const { return queue.empty(); }
118 bool full() const { return queue.full(); }
119 size_type size() const { return queue.size(); }
120 bool closed() const { return queue.closed(); }
121
122 // Modifiers
123 void close() { queue.close(); }
124
125
126 void push_back(const value_type& x) { queue.push_back(x); }
127
128 void pull_front(value_type& x) { queue.pull_front(x); };
129 // enable_if is_nothrow_copy_movable<value_type>
130 value_type pull_front() { return queue.pull_front(); }
131
132 queue_op_status try_push_back(const value_type& x) { return queue.try_push_back(x); }
133 queue_op_status try_pull_front(value_type& x) { return queue.try_pull_front(x); }
134
135 queue_op_status nonblocking_push_back(const value_type& x) { return queue.nonblocking_push_back(x); }
136 queue_op_status nonblocking_pull_front(value_type& x) { return queue.nonblocking_pull_front(x); }
137
138 queue_op_status wait_push_back(const value_type& x) { return queue.wait_push_back(x); }
139 queue_op_status wait_pull_front(value_type& x) { return queue.wait_pull_front(x); }
140
141 void push_back(BOOST_THREAD_RV_REF(value_type) x) { queue.push_back(boost::move(x)); }
142 queue_op_status try_push_back(BOOST_THREAD_RV_REF(value_type) x) { return queue.try_push_back(boost::move(x)); }
143 queue_op_status nonblocking_push_back(BOOST_THREAD_RV_REF(value_type) x) { return queue.nonblocking_push_back(boost::move(x)); }
144 queue_op_status wait_push_back(BOOST_THREAD_RV_REF(value_type) x) { return queue.wait_push_back(boost::move(x)); }
145 };
146
147
148 template <class Q, class T,
149 #if ! defined BOOST_NO_CXX11_RVALUE_REFERENCES
150 #if defined __GNUC__ && ! defined __clang__
151 #if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 5) || !defined(__GXX_EXPERIMENTAL_CXX0X__)
152 bool Copyable = is_copy_constructible<T>::value,
153 bool Movable = true
154 #else
155 bool Copyable = std::is_copy_constructible<T>::value && std::is_copy_assignable<T>::value,
156 bool Movable = std::is_move_constructible<T>::value && std::is_move_assignable<T>::value
157 #endif // __GNUC__
158 #elif defined _MSC_VER
159 #if _MSC_VER < 1700
160 bool Copyable = is_copy_constructible<T>::value,
161 bool Movable = true
162 #else
163 bool Copyable = std::is_copy_constructible<T>::value && std::is_copy_assignable<T>::value,
164 bool Movable = std::is_move_constructible<T>::value && std::is_move_assignable<T>::value
165 #endif // _MSC_VER
166 #else
167 bool Copyable = std::is_copy_constructible<T>::value && std::is_copy_assignable<T>::value,
168 bool Movable = std::is_move_constructible<T>::value && std::is_move_assignable<T>::value
169 #endif
170 #else
171 bool Copyable = is_copy_constructible<T>::value,
172 bool Movable = has_move_emulation_enabled<T>::value
173 #endif
174 >
175 struct deque_adaptor;
176
177 template <class Q, class T>
178 struct deque_adaptor<Q, T, true, true> {
179 typedef deque_adaptor_copyable_and_movable<Q> type;
180 };
181 template <class Q, class T>
182 struct deque_adaptor<Q, T, true, false> {
183 typedef deque_adaptor_copyable_only<Q> type;
184 };
185 template <class Q, class T>
186 struct deque_adaptor<Q, T, false, true> {
187 typedef deque_adaptor_movable_only<Q> type;
188 };
189
190 }
191
192 template <typename Queue>
193 class deque_adaptor :
194 public detail::deque_adaptor<Queue, typename Queue::value_type>::type
195 {
196 public:
197 typedef typename Queue::value_type value_type;
198 typedef typename Queue::size_type size_type;
199 // Constructors/Assignment/Destructors
200 virtual ~deque_adaptor() {};
201 };
202 }
203 using concurrent::deque_adaptor;
204
205 }
206
207 #include <boost/config/abi_suffix.hpp>
208
209 #endif