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/queue_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 queue_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 queue_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(x); }
0047
0048 queue_op_status try_push(const value_type& x) { return queue->try_push(x); }
0049
0050 queue_op_status nonblocking_push(const value_type& x) { return queue->nonblocking_push(x); }
0051 queue_op_status wait_push(const value_type& x) { return queue->wait_push(x); }
0052
0053 void push(BOOST_THREAD_RV_REF(value_type) x) { queue->push(boost::move(x)); }
0054 queue_op_status try_push(BOOST_THREAD_RV_REF(value_type) x) { return queue->try_push(boost::move(x)); }
0055 queue_op_status nonblocking_push(BOOST_THREAD_RV_REF(value_type) x) { return queue->nonblocking_push(boost::move(x)); }
0056 queue_op_status wait_push(BOOST_THREAD_RV_REF(value_type) x) { return queue->wait_push(boost::move(x)); }
0057 };
0058
0059 template <typename Queue>
0060 class queue_front_view
0061 {
0062 Queue* queue;
0063 public:
0064 typedef typename Queue::value_type value_type;
0065 typedef typename Queue::size_type size_type;
0066
0067
0068 queue_front_view(Queue& q) BOOST_NOEXCEPT : queue(&q) {}
0069
0070
0071 bool empty() const { return queue->empty(); }
0072 bool full() const { return queue->full(); }
0073 size_type size() const { return queue->size(); }
0074 bool closed() const { return queue->closed(); }
0075
0076
0077 void close() { queue->close(); }
0078
0079 void pull(value_type& x) { queue->pull(x); };
0080
0081 value_type pull() { return queue->pull(); }
0082
0083 queue_op_status try_pull(value_type& x) { return queue->try_pull(x); }
0084
0085 queue_op_status nonblocking_pull(value_type& x) { return queue->nonblocking_pull(x); }
0086
0087 queue_op_status wait_pull(value_type& x) { return queue->wait_pull(x); }
0088
0089 };
0090
0091 #if ! defined BOOST_NO_CXX11_TEMPLATE_ALIASES
0092
0093 template <class T>
0094 using queue_back = queue_back_view<queue_base<T> > ;
0095 template <class T>
0096 using queue_front = queue_front_view<queue_base<T> > ;
0097
0098 #else
0099
0100 template <class T>
0101 struct queue_back : queue_back_view<queue_base<T> >
0102 {
0103 typedef queue_back_view<queue_base<T> > base_type;
0104 queue_back(queue_base<T>& q) BOOST_NOEXCEPT : base_type(q) {}
0105 };
0106 template <class T>
0107 struct queue_front : queue_front_view<queue_base<T> >
0108 {
0109 typedef queue_front_view<queue_base<T> > base_type;
0110 queue_front(queue_base<T>& q) BOOST_NOEXCEPT : base_type(q) {}
0111
0112 };
0113
0114 #endif
0115
0116
0117
0118
0119
0120
0121
0122
0123
0124
0125
0126
0127
0128
0129
0130
0131 }
0132
0133 using concurrent::queue_back_view;
0134 using concurrent::queue_front_view;
0135 using concurrent::queue_back;
0136 using concurrent::queue_front;
0137
0138
0139
0140 }
0141
0142 #include <boost/config/abi_suffix.hpp>
0143
0144 #endif