File indexing completed on 2025-01-30 10:01:07
0001 #ifndef BOOST_THREAD_QUEUE_BASE_HPP
0002 #define BOOST_THREAD_QUEUE_BASE_HPP
0003
0004
0005
0006
0007
0008
0009
0010
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/type_traits/conditional.hpp>
0018 #include <boost/type_traits/is_copy_constructible.hpp>
0019
0020
0021 #include <boost/config/abi_prefix.hpp>
0022
0023 namespace boost
0024 {
0025 namespace concurrent
0026 {
0027 namespace detail
0028 {
0029
0030 template <typename ValueType, class SizeType>
0031 class queue_base_copyable_only
0032 {
0033 public:
0034 typedef ValueType value_type;
0035 typedef SizeType size_type;
0036
0037
0038 virtual ~queue_base_copyable_only() {};
0039
0040
0041 virtual bool empty() const = 0;
0042 virtual bool full() const = 0;
0043 virtual size_type size() const = 0;
0044 virtual bool closed() const = 0;
0045
0046
0047 virtual void close() = 0;
0048
0049 virtual void push(const value_type& x) = 0;
0050
0051 virtual void pull(value_type&) = 0;
0052 virtual value_type pull() = 0;
0053
0054 virtual queue_op_status try_push(const value_type& x) = 0;
0055 virtual queue_op_status try_pull(value_type&) = 0;
0056
0057 virtual queue_op_status nonblocking_push(const value_type& x) = 0;
0058 virtual queue_op_status nonblocking_pull(value_type&) = 0;
0059
0060 virtual queue_op_status wait_push(const value_type& x) = 0;
0061 virtual queue_op_status wait_pull(ValueType& elem) = 0;
0062
0063 };
0064
0065 template <typename ValueType, class SizeType>
0066 class queue_base_movable_only
0067 {
0068 public:
0069 typedef ValueType value_type;
0070 typedef SizeType size_type;
0071
0072 virtual ~queue_base_movable_only() {};
0073
0074
0075 virtual bool empty() const = 0;
0076 virtual bool full() const = 0;
0077 virtual size_type size() const = 0;
0078 virtual bool closed() const = 0;
0079
0080
0081 virtual void close() = 0;
0082
0083 virtual void pull(value_type&) = 0;
0084
0085 virtual value_type pull() = 0;
0086
0087 virtual queue_op_status try_pull(value_type&) = 0;
0088
0089 virtual queue_op_status nonblocking_pull(value_type&) = 0;
0090
0091 virtual queue_op_status wait_pull(value_type& elem) = 0;
0092
0093 virtual void push(BOOST_THREAD_RV_REF(value_type) x) = 0;
0094 virtual queue_op_status try_push(BOOST_THREAD_RV_REF(value_type) x) = 0;
0095 virtual queue_op_status nonblocking_push(BOOST_THREAD_RV_REF(value_type) x) = 0;
0096 virtual queue_op_status wait_push(BOOST_THREAD_RV_REF(value_type) x) = 0;
0097 };
0098
0099
0100 template <typename ValueType, class SizeType>
0101 class queue_base_copyable_and_movable
0102 {
0103 public:
0104 typedef ValueType value_type;
0105 typedef SizeType size_type;
0106
0107 virtual ~queue_base_copyable_and_movable() {};
0108
0109
0110
0111 virtual bool empty() const = 0;
0112 virtual bool full() const = 0;
0113 virtual size_type size() const = 0;
0114 virtual bool closed() const = 0;
0115
0116
0117 virtual void close() = 0;
0118
0119 virtual void push(const value_type& x) = 0;
0120
0121 virtual void pull(value_type&) = 0;
0122
0123 virtual value_type pull() = 0;
0124
0125 virtual queue_op_status try_push(const value_type& x) = 0;
0126 virtual queue_op_status try_pull(value_type&) = 0;
0127
0128 virtual queue_op_status nonblocking_push(const value_type& x) = 0;
0129 virtual queue_op_status nonblocking_pull(value_type&) = 0;
0130
0131 virtual queue_op_status wait_push(const value_type& x) = 0;
0132 virtual queue_op_status wait_pull(value_type& elem) = 0;
0133
0134 virtual void push(BOOST_THREAD_RV_REF(value_type) x) = 0;
0135 virtual queue_op_status try_push(BOOST_THREAD_RV_REF(value_type) x) = 0;
0136 virtual queue_op_status nonblocking_push(BOOST_THREAD_RV_REF(value_type) x) = 0;
0137 virtual queue_op_status wait_push(BOOST_THREAD_RV_REF(value_type) x) = 0;
0138 };
0139
0140 template <class T, class ST,
0141 #if ! defined BOOST_NO_CXX11_RVALUE_REFERENCES
0142 #if defined __GNUC__ && ! defined __clang__
0143 #if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 7) || !defined(__GXX_EXPERIMENTAL_CXX0X__)
0144 bool Copyable = is_copy_constructible<T>::value,
0145 bool Movable = true
0146 #else
0147 bool Copyable = std::is_copy_constructible<T>::value && std::is_copy_assignable<T>::value,
0148 bool Movable = std::is_move_constructible<T>::value && std::is_move_assignable<T>::value
0149 #endif
0150 #elif defined _MSC_VER
0151 #if _MSC_VER < 1700
0152 bool Copyable = is_copy_constructible<T>::value,
0153 bool Movable = true
0154 #else
0155 bool Copyable = std::is_copy_constructible<T>::value && std::is_copy_assignable<T>::value,
0156 bool Movable = std::is_move_constructible<T>::value && std::is_move_assignable<T>::value
0157 #endif
0158 #else
0159 bool Copyable = std::is_copy_constructible<T>::value && std::is_copy_assignable<T>::value,
0160 bool Movable = std::is_move_constructible<T>::value && std::is_move_assignable<T>::value
0161 #endif
0162 #else
0163 bool Copyable = is_copy_constructible<T>::value,
0164 bool Movable = has_move_emulation_enabled<T>::value
0165 #endif
0166 >
0167 struct queue_base;
0168
0169 template <class T, class ST>
0170 struct queue_base<T, ST, true, true> {
0171 typedef queue_base_copyable_and_movable<T, ST> type;
0172 };
0173 template <class T, class ST>
0174 struct queue_base<T, ST, true, false> {
0175 typedef queue_base_copyable_only<T, ST> type;
0176 };
0177 template <class T, class ST>
0178 struct queue_base<T, ST, false, true> {
0179 typedef queue_base_movable_only<T, ST> type;
0180 };
0181
0182 }
0183
0184 template <typename ValueType, class SizeType=std::size_t>
0185 class queue_base :
0186 public detail::queue_base<ValueType, SizeType>::type
0187 {
0188 public:
0189 typedef ValueType value_type;
0190 typedef SizeType size_type;
0191
0192 virtual ~queue_base() {};
0193 };
0194
0195 }
0196 using concurrent::queue_base;
0197
0198 }
0199
0200 #include <boost/config/abi_suffix.hpp>
0201
0202 #endif