File indexing completed on 2025-01-30 10:01:07
0001 #ifndef BOOST_THREAD_QUEUE_VIEWS_HPP
0002 #define BOOST_THREAD_QUEUE_VIEWS_HPP
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014 #include <boost/thread/detail/config.hpp>
0015 #include <boost/thread/detail/move.hpp>
0016 #include <boost/thread/concurrent_queues/queue_op_status.hpp>
0017 #include <boost/thread/concurrent_queues/deque_base.hpp>
0018
0019 #include <boost/config/abi_prefix.hpp>
0020
0021 namespace boost
0022 {
0023 namespace concurrent
0024 {
0025
0026 template <typename Queue>
0027 class deque_back_view
0028 {
0029 Queue* queue;
0030 public:
0031 typedef typename Queue::value_type value_type;
0032 typedef typename Queue::size_type size_type;
0033
0034
0035 deque_back_view(Queue& q) BOOST_NOEXCEPT : queue(&q) {}
0036
0037
0038 bool empty() const { return queue->empty(); }
0039 bool full() const { return queue->full(); }
0040 size_type size() const { return queue->size(); }
0041 bool closed() const { return queue->closed(); }
0042
0043
0044 void close() { queue->close(); }
0045
0046 void push(const value_type& x) { queue->push_back(x); }
0047
0048 void pull(value_type& x) { queue->pull_back(x); }
0049
0050 value_type pull() { return queue->pull_back(); }
0051
0052 queue_op_status try_push(const value_type& x) { return queue->try_push_back(x); }
0053
0054 queue_op_status try_pull(value_type& x) { return queue->try_pull_back(x); }
0055
0056 queue_op_status nonblocking_push(const value_type& x) { return queue->nonblocking_push_back(x); }
0057
0058 queue_op_status nonblocking_pull(value_type& x) { return queue->nonblocking_pull_back(x); }
0059
0060 queue_op_status wait_push(const value_type& x) { return queue->wait_push_back(x); }
0061 queue_op_status wait_pull(value_type& x) { return queue->wait_pull_back(x); }
0062
0063 void push(BOOST_THREAD_RV_REF(value_type) x) { queue->push_back(boost::move(x)); }
0064 queue_op_status try_push(BOOST_THREAD_RV_REF(value_type) x) { return queue->try_push_back(boost::move(x)); }
0065 queue_op_status nonblocking_push(BOOST_THREAD_RV_REF(value_type) x) { return queue->nonblocking_push_back(boost::move(x)); }
0066 queue_op_status wait_push(BOOST_THREAD_RV_REF(value_type) x) { return queue->wait_push_back(boost::move(x)); }
0067 };
0068
0069 template <typename Queue>
0070 class deque_front_view
0071 {
0072 Queue* queue;
0073 public:
0074 typedef typename Queue::value_type value_type;
0075 typedef typename Queue::size_type size_type;
0076
0077
0078 deque_front_view(Queue& q) BOOST_NOEXCEPT : queue(&q) {}
0079
0080
0081 bool empty() const { return queue->empty(); }
0082 bool full() const { return queue->full(); }
0083 size_type size() const { return queue->size(); }
0084 bool closed() const { return queue->closed(); }
0085
0086
0087 void close() { queue->close(); }
0088
0089 void push(const value_type& x) { queue->push_front(x); }
0090
0091 void pull(value_type& x) { queue->pull_front(x); };
0092
0093 value_type pull() { return queue->pull_front(); }
0094
0095 queue_op_status try_push(const value_type& x) { return queue->try_push_front(x); }
0096
0097 queue_op_status try_pull(value_type& x) { return queue->try_pull_front(x); }
0098
0099 queue_op_status nonblocking_push(const value_type& x) { return queue->nonblocking_push_front(x); }
0100
0101 queue_op_status nonblocking_pull(value_type& x) { return queue->nonblocking_pull_front(x); }
0102
0103 queue_op_status wait_push(const value_type& x) { return queue->wait_push_front(x); }
0104 queue_op_status wait_pull(value_type& x) { return queue->wait_pull_front(x); }
0105 void push(BOOST_THREAD_RV_REF(value_type) x) { queue->push_front(forward<value_type>(x)); }
0106 queue_op_status try_push(BOOST_THREAD_RV_REF(value_type) x) { return queue->try_push_front(forward<value_type>(x)); }
0107 queue_op_status nonblocking_push(BOOST_THREAD_RV_REF(value_type) x) { return queue->nonblocking_push_front(forward<value_type>(x)); }
0108 queue_op_status wait_push(BOOST_THREAD_RV_REF(value_type) x) { return queue->wait_push_front(forward<value_type>(x)); }
0109
0110 };
0111
0112 #if ! defined BOOST_NO_CXX11_TEMPLATE_ALIASES
0113
0114 template <class T>
0115 using deque_back = deque_back_view<deque_base<T> > ;
0116 template <class T>
0117 using deque_front = deque_front_view<deque_base<T> > ;
0118
0119 #else
0120
0121 template <class T>
0122 struct deque_back : deque_back_view<deque_base<T> >
0123 {
0124 typedef deque_back_view<deque_base<T> > base_type;
0125 deque_back(deque_base<T>& q) BOOST_NOEXCEPT : base_type(q) {}
0126 };
0127 template <class T>
0128 struct deque_front : deque_front_view<deque_base<T> >
0129 {
0130 typedef deque_front_view<deque_base<T> > base_type;
0131 deque_front(deque_base<T>& q) BOOST_NOEXCEPT : base_type(q) {}
0132
0133 };
0134
0135 #endif
0136
0137
0138
0139
0140
0141
0142
0143
0144
0145
0146
0147
0148
0149
0150
0151
0152 }
0153
0154 using concurrent::deque_back_view;
0155 using concurrent::deque_front_view;
0156 using concurrent::deque_back;
0157 using concurrent::deque_front;
0158
0159
0160
0161 }
0162
0163 #include <boost/config/abi_suffix.hpp>
0164
0165 #endif