9 #ifndef CPPCOMMON_THREADS_MPSC_RING_QUEUE_H
10 #define CPPCOMMON_THREADS_MPSC_RING_QUEUE_H
56 explicit operator bool() const noexcept {
return !
empty(); }
59 bool empty() const noexcept {
return (
size() == 0); }
61 size_t capacity() const noexcept {
return _capacity; }
65 size_t size() const noexcept;
108 bool Dequeue(const std::function<
void(const T&)>& handler = [](const
int&){});
114 SPSCRingQueue<T> queue;
121 std::vector<std::shared_ptr<Producer>> _producers;
Multiple producers / single consumer wait-free ring queue.
MPSCRingQueue(MPSCRingQueue &&)=delete
bool Dequeue(T &item)
Dequeue an item from the ring queue (single consumer threads method)
MPSCRingQueue(size_t capacity, size_t concurrency=std::thread::hardware_concurrency())
Default class constructor.
size_t size() const noexcept
Get ring queue size.
MPSCRingQueue(const MPSCRingQueue &)=delete
MPSCRingQueue & operator=(const MPSCRingQueue &)=delete
MPSCRingQueue & operator=(MPSCRingQueue &&)=delete
bool Enqueue(const T &item)
Enqueue an item into the ring queue (multiple producers threads method)
size_t capacity() const noexcept
Get ring queue capacity.
bool empty() const noexcept
Is ring queue empty?
size_t concurrency() const noexcept
Get ring queue concurrency.
Multiple producers / single consumer wait-free ring queue class inline implementation.
C++ Common project definitions.
Spin-lock synchronization primitive definition.
Single producer / single consumer wait-free ring queue definition.