Skip to content

Commit

Permalink
Comments added.
Browse files Browse the repository at this point in the history
  • Loading branch information
Maxim Egorushkin committed Mar 3, 2024
1 parent d995d64 commit ed6d587
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions include/atomic_queue/atomic_queue.h
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,7 @@ class AtomicQueueB : private std::allocator_traits<A>::template rebind_alloc<std
assert(std::atomic<T>{NIL}.is_lock_free()); // Queue element type T is not atomic. Use AtomicQueue2/AtomicQueueB2 for such element types.
for(auto p = elements_, q = elements_ + size_; p < q; ++p)
p->store(NIL, X);
assert(get_allocator() == allocator); // The standard requires the original and rebound allocators to manage the same state.
}

AtomicQueueB(AtomicQueueB&& b) noexcept
Expand All @@ -484,7 +485,7 @@ class AtomicQueueB : private std::allocator_traits<A>::template rebind_alloc<std
}

A get_allocator() const noexcept {
return *this;
return *this; // The standard requires implicit conversion between rebound allocators.
}

void swap(AtomicQueueB& b) noexcept {
Expand Down Expand Up @@ -564,6 +565,7 @@ class AtomicQueueB2 : private std::allocator_traits<A>::template rebind_alloc<un
for(auto p = states_, q = states_ + size_; p < q; ++p)
p->store(Base::EMPTY, X);
A a = get_allocator();
assert(a == allocator); // The standard requires stateful and rebound allocators to manage the same state.
for(auto p = elements_, q = elements_ + size_; p < q; ++p)
std::allocator_traits<A>::construct(a, p);
}
Expand Down Expand Up @@ -592,7 +594,7 @@ class AtomicQueueB2 : private std::allocator_traits<A>::template rebind_alloc<un
}

A get_allocator() const noexcept {
return *this;
return *this; // The standard requires implicit conversion between rebound allocators.
}

void swap(AtomicQueueB2& b) noexcept {
Expand Down

0 comments on commit ed6d587

Please sign in to comment.