1
1
/*
2
- Copyright (c) 2005-2023 Intel Corporation
2
+ Copyright (c) 2005-2025 Intel Corporation
3
3
4
4
Licensed under the Apache License, Version 2.0 (the "License");
5
5
you may not use this file except in compliance with the License.
@@ -48,7 +48,6 @@ std::pair<bool, ticket_type> internal_try_pop_impl(void* dst, QueueRep& queue, A
48
48
49
49
// A high-performance thread-safe non-blocking concurrent queue.
50
50
// Multiple threads may each push and pop concurrently.
51
- // Assignment construction is not allowed.
52
51
template <typename T, typename Allocator = tbb::cache_aligned_allocator<T>>
53
52
class concurrent_queue {
54
53
using allocator_traits_type = tbb::detail::allocator_traits<Allocator>;
@@ -317,7 +316,6 @@ namespace d2 {
317
316
// A high-performance thread-safe blocking concurrent bounded queue.
318
317
// Supports boundedness and blocking semantics.
319
318
// Multiple threads may each push and pop concurrently.
320
- // Assignment construction is not allowed.
321
319
template <typename T, typename Allocator = tbb::cache_aligned_allocator<T>>
322
320
class concurrent_bounded_queue {
323
321
using allocator_traits_type = tbb::detail::allocator_traits<Allocator>;
@@ -376,12 +374,14 @@ class concurrent_bounded_queue {
376
374
concurrent_bounded_queue ( const concurrent_bounded_queue& src, const allocator_type& a ) :
377
375
concurrent_bounded_queue (a)
378
376
{
377
+ my_capacity = src.my_capacity ;
379
378
my_queue_representation->assign (*src.my_queue_representation , my_allocator, copy_construct_item);
380
379
}
381
380
382
381
concurrent_bounded_queue ( const concurrent_bounded_queue& src ) :
383
382
concurrent_bounded_queue (queue_allocator_traits::select_on_container_copy_construction(src.get_allocator()))
384
383
{
384
+ my_capacity = src.my_capacity ;
385
385
my_queue_representation->assign (*src.my_queue_representation , my_allocator, copy_construct_item);
386
386
}
387
387
@@ -420,6 +420,7 @@ class concurrent_bounded_queue {
420
420
if (my_queue_representation != other.my_queue_representation ) {
421
421
clear ();
422
422
my_allocator = other.my_allocator ;
423
+ my_capacity = other.my_capacity ;
423
424
my_queue_representation->assign (*other.my_queue_representation , my_allocator, copy_construct_item);
424
425
}
425
426
return *this ;
@@ -435,6 +436,7 @@ class concurrent_bounded_queue {
435
436
my_queue_representation->assign (*other.my_queue_representation , other.my_allocator , move_construct_item);
436
437
other.clear ();
437
438
my_allocator = std::move (other.my_allocator );
439
+ my_capacity = other.my_capacity ;
438
440
}
439
441
}
440
442
return *this ;
@@ -547,8 +549,10 @@ class concurrent_bounded_queue {
547
549
548
550
private:
549
551
void internal_swap ( concurrent_bounded_queue& src ) {
550
- std::swap (my_queue_representation, src.my_queue_representation );
551
- std::swap (my_monitors, src.my_monitors );
552
+ using std::swap;
553
+ swap (my_queue_representation, src.my_queue_representation );
554
+ swap (my_capacity, src.my_capacity );
555
+ swap (my_monitors, src.my_monitors );
552
556
}
553
557
554
558
static constexpr std::ptrdiff_t infinite_capacity = std::ptrdiff_t (~size_type (0 ) / 2 );
0 commit comments