16 _producers.push_back(std::make_shared<Producer>(
capacity));
23 for (
const auto& producer : _producers)
24 size += producer->queue.size();
32 return Enqueue(std::forward<T>(temp));
45 return _producers[index]->queue.Enqueue(std::forward<T>(item));
52 for (
size_t i = 0; i < _concurrency; ++i)
54 if (_producers[_consumer++ % _concurrency]->queue.Dequeue(item))
64 assert((handler) &&
"Batch handler must be valid!");
69 for (
auto& producer : _producers)
72 while (producer->queue.Dequeue(item))
Locker synchronization primitive.
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.
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.
size_t concurrency() const noexcept
Get ring queue concurrency.
static uint64_t rdts()
Get the current value of RDTS (Read Time Stamp Counter)
C++ Common project definitions.