14 : m_size(
size), m_pushIndex(0), m_popIndex(0), m_count(0),
15 m_data((T*)operator new(
size * sizeof(T))),
16 m_openSlots(
size), m_fullSlots(0) {}
27 m_data[m_popIndex].~T();
28 m_popIndex = ++m_popIndex % m_size;
30 operator delete(m_data);
33 template<
typename Q = T>
34 typename std::enable_if<
35 std::is_copy_constructible<Q>::value &&
36 std::is_nothrow_copy_constructible<Q>::value,
void>::type
37 push(
const T& item) noexcept
41 std::lock_guard<std::mutex> lock(m_cs);
42 new (m_data + m_pushIndex) T(item);
43 m_pushIndex = ++m_pushIndex % m_size;
49 template<
typename Q = T>
50 typename std::enable_if<
51 std::is_copy_constructible<Q>::value &&
52 !std::is_nothrow_copy_constructible<Q>::value,
void>::type
57 std::lock_guard<std::mutex> lock(m_cs);
60 new (m_data + m_pushIndex) T(item);
67 m_pushIndex = ++m_pushIndex % m_size;
73 template<
typename Q = T>
74 typename std::enable_if<
75 std::is_move_constructible<Q>::value &&
76 std::is_nothrow_move_constructible<Q>::value,
void>::type
81 std::lock_guard<std::mutex> lock(m_cs);
82 new (m_data + m_pushIndex) T(std::move(item));
83 m_pushIndex = ++m_pushIndex % m_size;
89 template<
typename Q = T>
90 typename std::enable_if<
91 std::is_move_constructible<Q>::value &&
92 !std::is_nothrow_move_constructible<Q>::value,
void>::type
97 std::lock_guard<std::mutex> lock(m_cs);
100 new (m_data + m_pushIndex) T(std::move(item));
107 m_pushIndex = ++m_pushIndex % m_size;
113 template<
typename Q = T>
114 typename std::enable_if<
115 !std::is_move_assignable<Q>::value &&
116 std::is_nothrow_copy_assignable<Q>::value,
void>::type
121 std::lock_guard<std::mutex> lock(m_cs);
122 item = m_data[m_popIndex];
123 m_data[m_popIndex].~T();
124 m_popIndex = ++m_popIndex % m_size;
130 template<
typename Q = T>
131 typename std::enable_if<
132 !std::is_move_assignable<Q>::value &&
133 !std::is_nothrow_copy_assignable<Q>::value,
void>::type
138 std::lock_guard<std::mutex> lock(m_cs);
141 item = m_data[m_popIndex];
148 m_data[m_popIndex].~T();
149 m_popIndex = ++m_popIndex % m_size;
155 template<
typename Q = T>
156 typename std::enable_if<
157 std::is_move_assignable<Q>::value &&
158 std::is_nothrow_move_assignable<Q>::value,
void>::type
163 std::lock_guard<std::mutex> lock(m_cs);
164 item = std::move(m_data[m_popIndex]);
165 m_data[m_popIndex].~T();
166 m_popIndex = ++m_popIndex % m_size;
172 template<
typename Q = T>
173 typename std::enable_if<
174 std::is_move_assignable<Q>::value &&
175 !std::is_nothrow_move_assignable<Q>::value,
void>::type
180 std::lock_guard<std::mutex> lock(m_cs);
183 item = std::move(m_data[m_popIndex]);
190 m_data[m_popIndex].~T();
191 m_popIndex = ++m_popIndex % m_size;
206 std::lock_guard<std::mutex> lock(m_cs);
212 std::lock_guard<std::mutex> lock(m_cs);
222 const unsigned int m_size;
223 unsigned int m_pushIndex;
224 unsigned int m_popIndex;
225 unsigned int m_count;
std::enable_if< std::is_move_constructible< Q >::value &&std::is_nothrow_move_constructible< Q >::value, void >::type push(T &&item) noexcept
std::enable_if< !std::is_move_assignable< Q >::value &&!std::is_nothrow_copy_assignable< Q >::value, void >::type pop(T &item)
~blocking_queue() noexcept
unsigned int max_size() const noexcept
bool empty() const noexcept
std::enable_if< std::is_move_assignable< Q >::value &&!std::is_nothrow_move_assignable< Q >::value, void >::type pop(T &item)
blocking_queue(blocking_queue &&)=delete
std::enable_if< !std::is_move_assignable< Q >::value &&std::is_nothrow_copy_assignable< Q >::value, void >::type pop(T &item) noexcept
blocking_queue(unsigned int size)
std::enable_if< std::is_copy_constructible< Q >::value &&!std::is_nothrow_copy_constructible< Q >::value, void >::type push(const T &item)
blocking_queue(const blocking_queue &)=delete
blocking_queue & operator=(const blocking_queue &)=delete
bool size() const noexcept
std::enable_if< std::is_copy_constructible< Q >::value &&std::is_nothrow_copy_constructible< Q >::value, void >::type push(const T &item) noexcept
std::enable_if< std::is_move_constructible< Q >::value &&!std::is_nothrow_move_constructible< Q >::value, void >::type push(T &&item)
std::enable_if< std::is_move_assignable< Q >::value &&std::is_nothrow_move_assignable< Q >::value, void >::type pop(T &item) noexcept