| 351 | */ |
| 352 | template <typename Q, typename CopyFunc> |
| 353 | bool pop( Q* arr, size_t count, CopyFunc copy ) |
| 354 | { |
| 355 | assert( count < capacity()); |
| 356 | |
| 357 | counter_type front = front_.load( memory_model::memory_order_relaxed ); |
| 358 | assert( static_cast<size_t>( cback_ - front ) < capacity()); |
| 359 | |
| 360 | if ( static_cast<size_t>( cback_ - front ) < count ) { |
| 361 | cback_ = back_.load( memory_model::memory_order_acquire ); |
| 362 | if ( static_cast<size_t>( cback_ - front ) < count ) |
| 363 | return false; |
| 364 | } |
| 365 | |
| 366 | // copy data |
| 367 | value_cleaner cleaner; |
| 368 | for ( size_t i = 0; i < count; ++i, ++front ) { |
| 369 | value_type& val = buffer_[buffer_.mod( front )]; |
| 370 | copy( arr[i], val ); |
| 371 | cleaner( val ); |
| 372 | } |
| 373 | |
| 374 | front_.store( front, memory_model::memory_order_release ); |
| 375 | return true; |
| 376 | } |
| 377 | |
| 378 | /// Batch pop - push array \p arr of size \p count with assignment as copy functor |
| 379 | /** |