loon
High-performance data structures for latency-critical C++ applications.
A lightweight, header-only library with zero external dependencies. Drop-in STL replacements optimized for cache efficiency, low memory footprint, and real-time systems.
git clone https://github.com/jsrivaya/loon.git
#include <loon/ring_buffer.hpp>
#include <loon/lru.hpp>
#include <loon/spsc.hpp>
// Lock-free ring buffer — O(1) push/pop
loon::RingBuffer<int, 1024> buffer;
buffer.push(42);
auto val = buffer.pop();
// LRU cache — O(1) get/put
loon::LRUCache<std::string, int> cache(100);
cache.put("key", 99);
// SPSC queue — lock-free, wait-free
loon::SPSCQueue<double, 4096> q;
q.try_push(3.14);
Why loon?
Blazing Fast
Benchmarked against STL — faster insertion, lookup, and iteration. Optimized memory layout with SoA, pooling, and alignment.
Zero-Cost Abstractions
Header-only with no external dependencies. No dynamic allocation on critical paths. Ideal for real-time and embedded systems.
STL Compatible
Drop-in replacements with familiar interfaces. Swap out std:: types and immediately benefit from better performance.
Just Include It
Copy a header, include it, done. No build system changes, no linking, no configuration. C++17 and above.
Components
loon/ring_buffer.hpp
Ring Buffer
Fixed-size circular queue with O(1) push/pop. Cache-friendly contiguous memory layout.
loon/lru.hpp
LRU Cache
Least Recently Used cache with O(1) get/put. Constant-time eviction and lookup.
loon/redis_list.hpp
Redis List
Redis-style list with lpush, rpush, lpop, rpop, and lrange operations.
loon/spsc.hpp
SPSC Queue
Lock-free single-producer single-consumer queue. Wait-free for both producer and consumer.
Built for
High-frequency trading systems where every nanosecond counts
Game engines and real-time simulations with tight frame budgets
Resource-constrained systems with strict memory and latency requirements
Real-time processing pipelines for sensor data and control loops
Ready to dive in?
Get started with loon in under a minute. Header-only means zero friction.