9 #ifndef CPPCOMMON_THREADS_MPSC_RING_BUFFER_H
10 #define CPPCOMMON_THREADS_MPSC_RING_BUFFER_H
52 explicit operator bool() const noexcept {
return !
empty(); }
55 bool empty() const noexcept {
return (
size() == 0); }
57 size_t capacity() const noexcept {
return _capacity; }
61 size_t size() const noexcept;
99 std::vector<std::shared_ptr<Producer>> _producers;
Multiple producers / single consumer wait-free ring buffer.
bool empty() const noexcept
Is ring buffer empty?
MPSCRingBuffer & operator=(const MPSCRingBuffer &)=delete
size_t capacity() const noexcept
Get ring buffer capacity.
MPSCRingBuffer(const MPSCRingBuffer &)=delete
MPSCRingBuffer(size_t capacity, size_t concurrency=std::thread::hardware_concurrency())
Default class constructor.
size_t size() const noexcept
Get ring buffer size.
MPSCRingBuffer(MPSCRingBuffer &&)=delete
~MPSCRingBuffer()=default
MPSCRingBuffer & operator=(MPSCRingBuffer &&)=delete
bool Enqueue(const void *data, size_t size)
Enqueue a data into the ring buffer (single producer thread method)
size_t concurrency() const noexcept
Get ring buffer concurrency.
bool Dequeue(void *data, size_t &size)
Dequeue a data from the ring buffer (single consumer thread method)
Single producer / single consumer wait-free ring buffer.
Spin-lock synchronization primitive.
Multiple producers / single consumer wait-free ring buffer class inline implementation.
C++ Common project definitions.
Spin-lock synchronization primitive definition.
Single producer / single consumer wait-free ring buffer definition.