9 #ifndef CPPCOMMON_THREADS_SPSC_RING_QUEUE_H
10 #define CPPCOMMON_THREADS_SPSC_RING_QUEUE_H
50 explicit operator bool() const noexcept {
return !
empty(); }
53 bool empty() const noexcept {
return (
size() == 0); }
55 size_t capacity() const noexcept {
return _capacity; }
57 size_t size() const noexcept;
92 typedef
char cache_line_pad[128];
95 const
size_t _capacity;
100 std::atomic<
size_t> _head;
101 cache_line_pad _pad2;
102 std::atomic<
size_t> _tail;
103 cache_line_pad _pad3;
110 #include "spsc_ring_queue.inl"
Single producer / single consumer wait-free ring queue.
bool Enqueue(const T &item)
Enqueue an item into the ring queue (single producer thread method)
SPSCRingQueue(const SPSCRingQueue &)=delete
SPSCRingQueue & operator=(SPSCRingQueue &&)=delete
size_t size() const noexcept
Get ring queue size.
bool empty() const noexcept
Is ring queue empty?
size_t capacity() const noexcept
Get ring queue capacity.
SPSCRingQueue & operator=(const SPSCRingQueue &)=delete
SPSCRingQueue(size_t capacity)
Default class constructor.
bool Dequeue(T &item)
Dequeue an item from the ring queue (single consumer thread method)
SPSCRingQueue(SPSCRingQueue &&)=delete
C++ Common project definitions.