27 bool push(
const T& value) {
28 auto tail = tail_.load(std::memory_order_relaxed);
29 auto head = head_.load(std::memory_order_acquire);
30 if ((tail + 1) % capacity_ == head) {
35 tail_.store((tail + 1) % capacity_, std::memory_order_release);
49 auto tail = tail_.load(std::memory_order_acquire);
50 auto head = head_.load(std::memory_order_relaxed);
56 head_.store((head_ + 1) % capacity_, std::memory_order_release);
63 size_t capacity()
const {
return capacity_ - 1; }
67 bool empty()
const {
return head_ == tail_; }
72 return (tail_.load(std::memory_order_acquire) + 1) % capacity_ ==
73 head_.load(std::memory_order_acquire);
79 std::atomic<size_t> head_{0};
80 std::atomic<size_t> tail_{0};