rzbdz / spsc_ring

a single producer single customer lock-free (atomic) queue

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

spsc_ring

a single producer single customer lock-free (atomic) queue, initially write for a async logging module

lock-free single producer single consumer ring buffer (bounded)

It's simple to implement a lock free SPSC ring buffer for there won't be any contention. But there are some details need to be handled to implement correctly and with high efficiency.

NOTICE: This implementation is modeled after Intel DPDK::rte_ring and Linux kernel::kfifo

design documentation of DPDK::rte_ring:

feature:

  • use malloc and in-place constructor, free + in-place destructor to support non-POD types,
  • emplace
  • support batch dequeue

further improvement: use atomic instead of volatile + memory fence

testing:

make test

About

a single producer single customer lock-free (atomic) queue


Languages

Language:C++ 99.4%Language:Makefile 0.6%