21 template<
typename T,
size_t Size>
30 CircularBuffer() : tail_(0), head_(0)
32 if(!tail_.is_lock_free())
34 mc_rtc::log::warning(
"Your platform does not support std::atomic_size_t as lock free operations");
39 bool push(
const T & item)
42 auto next_tail = increment(tail);
43 if(next_tail != head_)
55 const size_t head = head_;
56 if(head == tail_) {
return false; }
58 head_ = increment(head);
63 bool empty() {
return head_ == tail_; }
66 size_t increment(
size_t idx)
const {
return (idx + 1) % Capacity; }
69 std::atomic_size_t tail_;
70 std::atomic_size_t head_;