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/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     // Constructors/Assignment/Destructors
0035     queue_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(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     // Constructors/Assignment/Destructors
0068     queue_front_view(Queue& q) BOOST_NOEXCEPT : queue(&q) {}
0069 
0070     // Observers
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     // Modifiers
0077     void close() { queue->close(); }
0078 
0079     void pull(value_type& x) { queue->pull(x); };
0080     // enable_if is_nothrow_copy_movable<value_type>
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 //  template <class Queue>
0117 //  queue_back_view<Queue> back(Queue & q) { return queue_back_view<Queue>(q); }
0118 //  template <class Queue>
0119 //  queue_front_view<Queue> front(Queue & q) { return queue_front_view<Queue>(q); }
0120 //#if 0
0121 //  template <class T>
0122 //  queue_back<T> back(queue_base<T> & q) { return queue_back<T>(q); }
0123 //  template <class T>
0124 //  queue_front<T> front(queue_base<T> & q) { return queue_front<T>(q); }
0125 //#else
0126 //  template <class T>
0127 //  typename queue_back<T>::type back(queue_base<T> & q) { return typename queue_back<T>::type(q); }
0128 //  template <class T>
0129 //  typename queue_front<T>::type front(queue_base<T> & q) { return typename queue_front<T>::type(q); }
0130 //#endif
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 //using concurrent::back;
0138 //using concurrent::front;
0139 
0140 }
0141 
0142 #include <boost/config/abi_suffix.hpp>
0143 
0144 #endif