Back to home page

EIC code displayed by LXR

 
 

    


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 // (C) Copyright Vicente J. Botet Escriba 2014. Distributed under the Boost
0007 // Software License, Version 1.0. (See accompanying file
0008 // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
0009 //
0010 // See http://www.boost.org/libs/thread for documentation.
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     // Constructors/Assignment/Destructors
0035     deque_back_view(Queue& q) BOOST_NOEXCEPT : queue(&q) {}
0036 
0037     // Observers
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     // Modifiers
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     // enable_if is_nothrow_copy_movable<value_type>
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     // Constructors/Assignment/Destructors
0078     deque_front_view(Queue& q) BOOST_NOEXCEPT : queue(&q) {}
0079 
0080     // Observers
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     // Modifiers
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     // enable_if is_nothrow_copy_movable<value_type>
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 //  template <class Queue>
0138 //  deque_back_view<Queue> back(Queue & q) { return deque_back_view<Queue>(q); }
0139 //  template <class Queue>
0140 //  deque_front_view<Queue> front(Queue & q) { return deque_front_view<Queue>(q); }
0141 //#if 0
0142 //  template <class T>
0143 //  deque_back<T> back(deque_base<T> & q) { return deque_back<T>(q); }
0144 //  template <class T>
0145 //  deque_front<T> front(deque_base<T> & q) { return deque_front<T>(q); }
0146 //#else
0147 //  template <class T>
0148 //  typename deque_back<T>::type back(deque_base<T> & q) { return typename deque_back<T>::type(q); }
0149 //  template <class T>
0150 //  typename deque_front<T>::type front(deque_base<T> & q) { return typename deque_front<T>::type(q); }
0151 //#endif
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 //using concurrent::back;
0159 //using concurrent::front;
0160 
0161 }
0162 
0163 #include <boost/config/abi_suffix.hpp>
0164 
0165 #endif