| 195 | */ |
| 196 | template <typename Q, typename CopyFunc> |
| 197 | bool push( Q* arr, size_t count, CopyFunc copy ) |
| 198 | { |
| 199 | assert( count < capacity()); |
| 200 | counter_type back = back_.load( memory_model::memory_order_relaxed ); |
| 201 | |
| 202 | assert( static_cast<size_t>( back - pfront_ ) <= capacity()); |
| 203 | |
| 204 | if ( static_cast<size_t>( pfront_ + capacity() - back ) < count ) { |
| 205 | pfront_ = front_.load( memory_model::memory_order_acquire ); |
| 206 | |
| 207 | if ( static_cast<size_t>( pfront_ + capacity() - back ) < count ) { |
| 208 | // not enough space |
| 209 | return false; |
| 210 | } |
| 211 | } |
| 212 | |
| 213 | // copy data |
| 214 | for ( size_t i = 0; i < count; ++i, ++back ) |
| 215 | copy( buffer_[buffer_.mod( back )], arr[i] ); |
| 216 | |
| 217 | back_.store( back, memory_model::memory_order_release ); |
| 218 | |
| 219 | return true; |
| 220 | } |
| 221 | |
| 222 | /// Batch push - push array \p arr of size \p count with assignment as copy functor |
| 223 | /** |