#ifndef BOOST_THREAD_QUEUE_ADAPTOR_HPP #define BOOST_THREAD_QUEUE_ADAPTOR_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 { namespace detail { template class queue_adaptor_copyable_only : public boost::queue_base { Queue queue; public: typedef typename Queue::value_type value_type; typedef std::size_t size_type; // Constructors/Assignment/Destructors queue_adaptor_copyable_only() {} // 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_back(const value_type& x) { queue.push_back(x); } void pull_front(value_type& x) { queue.pull_front(x); }; value_type pull_front() { return queue.pull_front(); } queue_op_status try_push_back(const value_type& x) { return queue.try_push_back(x); } queue_op_status try_pull_front(value_type& x) { return queue.try_pull_front(x); } queue_op_status nonblocking_push_back(const value_type& x) { return queue.nonblocking_push_back(x); } queue_op_status nonblocking_pull_front(value_type& x) { return queue.nonblocking_pull_front(x); } queue_op_status wait_push_back(const value_type& x) { return queue.wait_push_back(x); } queue_op_status wait_pull_front(value_type& x) { return queue.wait_pull_front(x); } }; template class queue_adaptor_movable_only : public boost::queue_base { Queue queue; public: typedef typename Queue::value_type value_type; typedef std::size_t size_type; // Constructors/Assignment/Destructors queue_adaptor_movable_only() {} // 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 pull_front(value_type& x) { queue.pull_front(x); }; // enable_if is_nothrow_copy_movable value_type pull_front() { return queue.pull_front(); } queue_op_status try_pull_front(value_type& x) { return queue.try_pull_front(x); } queue_op_status nonblocking_pull_front(value_type& x) { return queue.nonblocking_pull_front(x); } queue_op_status wait_pull_front(value_type& x) { return queue.wait_pull_front(x); } void push_back(BOOST_THREAD_RV_REF(value_type) x) { queue.push_back(boost::move(x)); } queue_op_status try_push_back(BOOST_THREAD_RV_REF(value_type) x) { return queue.try_push_back(boost::move(x)); } queue_op_status nonblocking_push_back(BOOST_THREAD_RV_REF(value_type) x) { return queue.nonblocking_push_back(boost::move(x)); } queue_op_status wait_push_back(BOOST_THREAD_RV_REF(value_type) x) { return queue.wait_push_back(boost::move(x)); } }; template class queue_adaptor_copyable_and_movable : public boost::queue_base { Queue queue; public: typedef typename Queue::value_type value_type; typedef std::size_t size_type; // Constructors/Assignment/Destructors queue_adaptor_copyable_and_movable() {} // 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_back(const value_type& x) { queue.push_back(x); } void pull_front(value_type& x) { queue.pull_front(x); }; // enable_if is_nothrow_copy_movable value_type pull_front() { return queue.pull_front(); } queue_op_status try_push_back(const value_type& x) { return queue.try_push_back(x); } queue_op_status try_pull_front(value_type& x) { return queue.try_pull_front(x); } queue_op_status nonblocking_push_back(const value_type& x) { return queue.nonblocking_push_back(x); } queue_op_status nonblocking_pull_front(value_type& x) { return queue.nonblocking_pull_front(x); } queue_op_status wait_push_back(const value_type& x) { return queue.wait_push_back(x); } queue_op_status wait_pull_front(value_type& x) { return queue.wait_pull_front(x); } void push_back(BOOST_THREAD_RV_REF(value_type) x) { queue.push_back(boost::move(x)); } queue_op_status try_push_back(BOOST_THREAD_RV_REF(value_type) x) { return queue.try_push_back(boost::move(x)); } queue_op_status nonblocking_push_back(BOOST_THREAD_RV_REF(value_type) x) { return queue.nonblocking_push_back(boost::move(x)); } queue_op_status wait_push_back(BOOST_THREAD_RV_REF(value_type) x) { return queue.wait_push_back(boost::move(x)); } }; template ::value, bool Movable = true #else bool Copyable = std::is_copy_constructible::value && std::is_copy_assignable::value, bool Movable = std::is_move_constructible::value && std::is_move_assignable::value #endif // __GNUC__ #elif defined _MSC_VER #if _MSC_VER < 1700 bool Copyable = is_copy_constructible::value, bool Movable = true #else bool Copyable = std::is_copy_constructible::value && std::is_copy_assignable::value, bool Movable = std::is_move_constructible::value && std::is_move_assignable::value #endif // _MSC_VER #else bool Copyable = std::is_copy_constructible::value && std::is_copy_assignable::value, bool Movable = std::is_move_constructible::value && std::is_move_assignable::value #endif #else bool Copyable = is_copy_constructible::value, bool Movable = has_move_emulation_enabled::value #endif > struct queue_adaptor; template struct queue_adaptor { typedef queue_adaptor_copyable_and_movable type; }; template struct queue_adaptor { typedef queue_adaptor_copyable_only type; }; template struct queue_adaptor { typedef queue_adaptor_movable_only type; }; } template class queue_adaptor : public detail::queue_adaptor::type { public: typedef typename Queue::value_type value_type; typedef std::size_t size_type; // Constructors/Assignment/Destructors virtual ~queue_adaptor() {}; }; } using concurrent::queue_adaptor; } #include #endif