A fast, Flask-style C++ microframework for building HTTP and WebSocket web services, header-only and easy to use.
max0x7ba/atomic_queue
Header-only C++14 lock-free ring-buffer queues for passing messages between threads with minimal push-to-pop latency.
- Stars
- 1,899
- Forks
- 221
- Open issues
- 1
- Last commit
- 7 days ago
What is it?
atomic_queue is a set of header-only C++14 multiple-producer, multiple-consumer queues built on fixed-capacity ring buffers and std::atomic. Its stated goal is to minimise the time between one thread pushing an element and another thread popping it, so it is aimed at latency-sensitive code such as trading systems and logging hot paths.
The queues use a fixed capacity set at compile time or construction, so no heap allocation happens after construction. Variants exist for atomic element types and for non-atomic types such as std::unique_ptr, with array-backed and heap-backed buffers. Position-independent array-based variants can be placed in shared memory for inter-process use. Both spin-waiting push/pop and non-blocking try_push/try_pop forms are provided, along with an SPSC mode that avoids read-modify-write atomics.
The project is tested in CI on Linux x86_64 and ARM, plus cross-architecture runs under QEMU for RISC-V, PowerPC, s390x and LoongArch, and on Windows x86_64 and macOS ARM via CMake. It can be consumed through CMake, vcpkg or Conan.
Key features
- 01Header-only C++14 library with no build step required to use it.
- 02Fixed-capacity ring buffers with no heap allocation after construction.
- 03Variants for atomic and non-atomic element types, including move-only types like std::unique_ptr.
- 04Position-independent array-based queues that can live in shared memory.
- 05Optional totally ordered FIFO mode for push and pop.
- 06Non-blocking try_push/try_pop and spin-waiting push/pop forms.
Use cases
- Passing market data or orders between threads in latency-sensitive trading software.
- Offloading log records from a hot path to a background formatting and I/O thread.
- Passing small messages between processes through a shared-memory segment.
- Distributing tasks from producers to a pool of worker threads with bounded capacity.
Things to know
- The queue capacity is fixed at compile time or construction time, so it cannot grow.
- There are no OS-blocking push or pop functions, so waiting threads spin and consume CPU.
- It was developed and benchmarked mainly on Linux x86_64, so other platforms are less proven.
Topics
FAQ
- What is atomic_queue?
- Header-only C++14 lock-free ring-buffer queues for passing messages between threads with minimal push-to-pop latency. atomic_queue is a set of header-only C++14 multiple-producer, multiple-consumer queues built on fixed-capacity ring buffers and std::atomic. Its stated goal is to minimise the time between one thread pushing an element and another thread popping it, so it is aimed at latency-sensitive code such as trading systems and logging hot paths.
- Is atomic_queue free to use? What license does it have?
- atomic_queue is open source under the MIT license. Check the license terms before using it in commercial products.
- Is atomic_queue still maintained?
- Actively maintained. The last commit to atomic_queue was on Oct 16, 2026.
- What can I use atomic_queue for?
- Passing market data or orders between threads in latency-sensitive trading software. Offloading log records from a hot path to a background formatting and I/O thread. Passing small messages between processes through a shared-memory segment. Distributing tasks from producers to a pool of worker threads with bounded capacity.
- Where can I get atomic_queue?
- The source code and installation instructions are on GitHub: https://github.com/max0x7ba/atomic_queue
Summary generated by AI from the project's README. GitHub stats refresh daily.
Related projects
A header-only C++11 library that lets C++ code parse, build, manipulate and serialize JSON with STL-like syntax.
A C++ formatting library offering a fast, type-safe alternative to C stdio and iostreams, implementing C++20 std::format.
Ultra-low-latency asynchronous C++17 logging and metrics library that defers formatting and I/O to a background thread.
An orchestration engine for background tasks, AI agents and durable workflows, with Python, TypeScript, Go and Ruby SDKs and Postgres as its durability layer.
A small add-on for Python's requests library that sends HTTP requests asynchronously using concurrent.futures.