This repository provides a high-performance, header-only C++11 library implementing a lock-free, wait-free single-producer single-consumer (SPSC) queue (ReaderWriterQueue) and a blocking variant (BlockingReaderWriterQueue). The core design uses a queue-of-blocks architecture with circular buffers to minimize memory allocation and contention. It also includes a fixed-size blocking circular buffer (BlockingReaderWriterCircularBuffer) with support for timed waits. The library is built on top of a portable atomic operations layer (atomicops.h) that abstracts memory barriers, compiler fences, and a lightweight semaphore across Windows, macOS, Linux, and FreeRTOS. The code demonstrates exceptional attention to cache-line padding, memory ordering, and elimination of false sharing, making it suitable for ultra-low-latency inter-thread communication. It is extensively tested with unit tests and stability tests, and includes benchmarks comparing performance against other SPSC queues such as Dmitry Vyukov's and Facebook's folly. The library is single-purpose, self-contained, and easily integrable into any C++ project via drop-in headers or CMake FetchContent.
lockfree is a header-only C++11 library providing lock-free data structures for concurrent programming. It offers both single-producer single-consumer (SPSC) and multi-producer multi-consumer (MPMC) variants of queues, ring buffers, bipartite buffers, and priority queues. The library is designed for use across a wide spectrum of systems from deeply embedded to HPC, featuring no dynamic allocation and optimized for high performance. Architecture-wise, it's organized into spsc/ and mpmc/ namespaces with each data structure having separate header and implementation files, aggregated through lockfree.hpp. The implementation uses atomic operations and clever algorithms to achieve lock-free behavior without mutexes.