#ifndef BOOST_THREAD_QUEUE_VIEWS_HPP #define BOOST_THREAD_QUEUE_VIEWS_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 #include #include #include #include namespace boost { namespace concurrent { template class queue_back_view { Queue* queue; public: typedef typename Queue::value_type value_type; typedef typename Queue::size_type size_type; // Constructors/Assignment/Destructors queue_back_view(Queue& q) BOOST_NOEXCEPT : queue(&q) {} // 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); } queue_op_status try_push(const value_type& x) { return queue->try_push(x); } queue_op_status nonblocking_push(const value_type& x) { return queue->nonblocking_push(x); } queue_op_status wait_push(const value_type& x) { return queue->wait_push(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 queue_front_view { Queue* queue; public: typedef typename Queue::value_type value_type; typedef typename Queue::size_type size_type; // Constructors/Assignment/Destructors queue_front_view(Queue& q) BOOST_NOEXCEPT : queue(&q) {} // 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_front(x); } void pull(value_type& x) { queue->pull(x); }; // enable_if is_nothrow_copy_movable value_type pull() { return queue->pull(); } queue_op_status try_push(const value_type& x) { return queue->try_push_front(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_front(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_front(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_front(forward(x)); } queue_op_status try_push(BOOST_THREAD_RV_REF(value_type) x) { return queue->try_push_front(forward(x)); } queue_op_status nonblocking_push(BOOST_THREAD_RV_REF(value_type) x) { return queue->nonblocking_push_front(forward(x)); } queue_op_status wait_push(BOOST_THREAD_RV_REF(value_type) x) { return queue->wait_push_front(forward(x)); } }; #if ! defined BOOST_NO_CXX11_TEMPLATE_ALIASES template using queue_back = queue_back_view > ; template using queue_front = queue_front_view > ; #else template struct queue_back : queue_back_view > { typedef queue_back_view > base_type; queue_back(queue_base& q) BOOST_NOEXCEPT : base_type(q) {} }; template struct queue_front : queue_front_view > { typedef queue_front_view > base_type; queue_front(queue_base& q) BOOST_NOEXCEPT : base_type(q) {} }; #endif // template // queue_back_view back(Queue & q) { return queue_back_view(q); } // template // queue_front_view front(Queue & q) { return queue_front_view(q); } //#if 0 // template // queue_back back(queue_base & q) { return queue_back(q); } // template // queue_front front(queue_base & q) { return queue_front(q); } //#else // template // typename queue_back::type back(queue_base & q) { return typename queue_back::type(q); } // template // typename queue_front::type front(queue_base & q) { return typename queue_front::type(q); } //#endif } using concurrent::queue_back_view; using concurrent::queue_front_view; using concurrent::queue_back; using concurrent::queue_front; //using concurrent::back; //using concurrent::front; } #include #endif