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