123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165 |
- #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 <boost/thread/detail/config.hpp>
- #include <boost/thread/detail/move.hpp>
- #include <boost/thread/concurrent_queues/queue_op_status.hpp>
- #include <boost/thread/concurrent_queues/deque_base.hpp>
- #include <boost/config/abi_prefix.hpp>
- namespace boost
- {
- namespace concurrent
- {
- template <typename Queue>
- class deque_back_view
- {
- Queue* queue;
- public:
- typedef typename Queue::value_type value_type;
- typedef typename Queue::size_type size_type;
- // Constructors/Assignment/Destructors
- deque_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_back(x); }
- void pull(value_type& x) { queue->pull_back(x); }
- // enable_if is_nothrow_copy_movable<value_type>
- value_type pull() { return queue->pull_back(); }
- queue_op_status try_push(const value_type& x) { return queue->try_push_back(x); }
- queue_op_status try_pull(value_type& x) { return queue->try_pull_back(x); }
- queue_op_status nonblocking_push(const value_type& x) { return queue->nonblocking_push_back(x); }
- queue_op_status nonblocking_pull(value_type& x) { return queue->nonblocking_pull_back(x); }
- queue_op_status wait_push(const value_type& x) { return queue->wait_push_back(x); }
- queue_op_status wait_pull(value_type& x) { return queue->wait_pull_back(x); }
- void push(BOOST_THREAD_RV_REF(value_type) x) { queue->push_back(boost::move(x)); }
- queue_op_status try_push(BOOST_THREAD_RV_REF(value_type) x) { return queue->try_push_back(boost::move(x)); }
- queue_op_status nonblocking_push(BOOST_THREAD_RV_REF(value_type) x) { return queue->nonblocking_push_back(boost::move(x)); }
- queue_op_status wait_push(BOOST_THREAD_RV_REF(value_type) x) { return queue->wait_push_back(boost::move(x)); }
- };
- template <typename Queue>
- class deque_front_view
- {
- Queue* queue;
- public:
- typedef typename Queue::value_type value_type;
- typedef typename Queue::size_type size_type;
- // Constructors/Assignment/Destructors
- deque_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_front(x); };
- // enable_if is_nothrow_copy_movable<value_type>
- value_type pull() { return queue->pull_front(); }
- 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_front(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_front(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_front(x); }
- void push(BOOST_THREAD_RV_REF(value_type) x) { queue->push_front(forward<value_type>(x)); }
- queue_op_status try_push(BOOST_THREAD_RV_REF(value_type) x) { return queue->try_push_front(forward<value_type>(x)); }
- queue_op_status nonblocking_push(BOOST_THREAD_RV_REF(value_type) x) { return queue->nonblocking_push_front(forward<value_type>(x)); }
- queue_op_status wait_push(BOOST_THREAD_RV_REF(value_type) x) { return queue->wait_push_front(forward<value_type>(x)); }
- };
- #if ! defined BOOST_NO_CXX11_TEMPLATE_ALIASES
- template <class T>
- using deque_back = deque_back_view<deque_base<T> > ;
- template <class T>
- using deque_front = deque_front_view<deque_base<T> > ;
- #else
- template <class T>
- struct deque_back : deque_back_view<deque_base<T> >
- {
- typedef deque_back_view<deque_base<T> > base_type;
- deque_back(deque_base<T>& q) BOOST_NOEXCEPT : base_type(q) {}
- };
- template <class T>
- struct deque_front : deque_front_view<deque_base<T> >
- {
- typedef deque_front_view<deque_base<T> > base_type;
- deque_front(deque_base<T>& q) BOOST_NOEXCEPT : base_type(q) {}
- };
- #endif
- // template <class Queue>
- // deque_back_view<Queue> back(Queue & q) { return deque_back_view<Queue>(q); }
- // template <class Queue>
- // deque_front_view<Queue> front(Queue & q) { return deque_front_view<Queue>(q); }
- //#if 0
- // template <class T>
- // deque_back<T> back(deque_base<T> & q) { return deque_back<T>(q); }
- // template <class T>
- // deque_front<T> front(deque_base<T> & q) { return deque_front<T>(q); }
- //#else
- // template <class T>
- // typename deque_back<T>::type back(deque_base<T> & q) { return typename deque_back<T>::type(q); }
- // template <class T>
- // typename deque_front<T>::type front(deque_base<T> & q) { return typename deque_front<T>::type(q); }
- //#endif
- }
- using concurrent::deque_back_view;
- using concurrent::deque_front_view;
- using concurrent::deque_back;
- using concurrent::deque_front;
- //using concurrent::back;
- //using concurrent::front;
- }
- #include <boost/config/abi_suffix.hpp>
- #endif
|