A modern C++20 library implementing lock-free, high-performance concurrent data structures demonstrating advanced C++ programming skills and best practices.
- Lock-Free Queue: Wait-free enqueue/dequeue operations using atomic operations
- Lock-Free Hash Map: High-performance concurrent hash map with fine-grained synchronization
- Thread Pool: Efficient thread pool with work-stealing capabilities
- Interactive GUI: Real-time monitoring and visualization tool with performance metrics
- Modern C++20: Utilizes latest C++ features (concepts, ranges, smart pointers, etc.)
- Zero Dependencies: Core library has no external dependencies (except for testing)
- Comprehensive Tests: Full test coverage using Google Test
- Performance Benchmarks: Built-in benchmarking suite
The project includes a comprehensive GUI monitoring application built with ImGui that provides real-time visualization and interaction with all data structures.
- Real-time Monitoring: Live statistics and metrics for all data structures
- Tabbed Interface: Organized tabs for Queue, Hash Map, Thread Pool, and Performance
- Visual Graphs: Queue size, active tasks, throughput, and latency history
- Interactive Controls: Test operations directly from the GUI
- Performance Metrics: Latency tracking, throughput calculation, and operation timing
- Queue Visualization: Visual representation of queue contents
- Export Functionality: Export statistics to file
Overview of the GUI showing all tabs and real-time monitoring
Queue tab with auto producer/consumer and visualization
Hash map operations and statistics
Thread pool monitoring with task submission
Performance tab with latency and throughput graphs
cd build
./guiTo create GIFs of the GUI in action, use the provided recording scripts:
# Simple recording (20 seconds)
cd scripts
./record_simple.sh 20 gui_demo
# Advanced recording (requires xdotool)
./record_gui.sh gui_demoThe GIFs will be saved to docs/images/ directory.
- C++20 compatible compiler (GCC 10+, Clang 12+, MSVC 2019+)
- CMake 3.20 or higher
- (Optional) Google Test for running tests
# Create build directory
mkdir build
cd build
# Configure
cmake ..
# Build
cmake --build . --config Release
# Run tests
ctest
# Run benchmarks
./benchmark
# Run examples
./example
# Run GUI application
./gui#include "concurrent/lockfree_queue.hpp"
concurrent::LockFreeQueue<int> queue;
// Producer thread
queue.enqueue(42);
// Consumer thread
auto item = queue.dequeue();
if (item.has_value()) {
std::cout << "Got: " << item.value() << std::endl;
}#include "concurrent/lockfree_hashmap.hpp"
concurrent::LockFreeHashMap<std::string, int> map;
// Insert
map.insert("key", 100);
// Retrieve
if (auto value = map.get("key")) {
std::cout << "Value: " << value.value() << std::endl;
}
// Check existence
if (map.contains("key")) {
// ...
}
// Remove
map.erase("key");#include "concurrent/thread_pool.hpp"
concurrent::ThreadPool pool(4); // 4 worker threads
// Submit task
auto future = pool.submit([]() {
return 42;
});
int result = future.get();
// Wait for all tasks
pool.wait();- C++20 features (concepts, ranges, coroutines-ready design)
- RAII and smart pointers
- Move semantics and perfect forwarding
- Template metaprogramming
- Lock-free programming techniques
- Memory ordering and atomic operations
- Cache-line alignment for false sharing prevention
- Wait-free algorithms
- Zero-copy where possible
- Cache-friendly data structures
- Minimal memory allocations
- High-throughput design
- Clean architecture and separation of concerns
- Comprehensive unit tests
- CMake build system
- Professional documentation
- Production-ready code quality
- Thread-safe by design
- Scalable to many cores
- Suitable for high-frequency trading, game engines, and server applications
- Queue: O(1) enqueue/dequeue, lock-free, wait-free
- Hash Map: O(1) average case insert/lookup, lock-free reads
- Thread Pool: Minimal overhead, efficient work distribution
The project includes comprehensive unit tests covering:
- Basic functionality
- Concurrent operations
- Edge cases
- Thread safety
- Performance characteristics
Run tests with:
cd build
ctest --verbose.
βββ CMakeLists.txt # Build configuration
βββ README.md # This file
βββ include/
β βββ concurrent/
β βββ lockfree_queue.hpp
β βββ lockfree_hashmap.hpp
β βββ thread_pool.hpp
βββ src/
β βββ lockfree_queue.cpp
β βββ lockfree_hashmap.cpp
β βββ thread_pool.cpp
βββ tests/
β βββ test_lockfree_queue.cpp
β βββ test_lockfree_hashmap.cpp
β βββ test_thread_pool.cpp
βββ benchmarks/
β βββ main.cpp
βββ examples/
β βββ main.cpp
βββ gui/
β βββ main.cpp
βββ scripts/
β βββ record_gui.sh
β βββ record_simple.sh
βββ docs/
βββ images/ # GIFs and screenshots
- Uses atomic compare-and-swap operations
- Memory ordering: acquire-release semantics
- Node-based linked list structure
- Wait-free for both enqueue and dequeue
- Bucket-based hash table
- Fine-grained synchronization per bucket
- Mark-and-sweep deletion strategy
- Configurable bucket count and hash function
- Lock-free task queue
- Work-stealing ready (can be extended)
- Efficient task distribution
- Graceful shutdown
This project demonstrates:
- Advanced C++ programming
- Concurrent programming patterns
- Lock-free algorithm design
- Performance optimization techniques
- Professional software development practices
This project is provided as a portfolio piece. Feel free to use it for learning and demonstration purposes.
This is a showcase project, but suggestions and improvements are welcome!
Built with passion for high-performance C++ programming π