A Bonity's C++ standard library — a header-only concurrency library implemented in C++26, covering parallel algorithms, thread-safe containers and lock-free data structures.
- You can use
git clone https://github.com/BoningtonChen/Bonostlto clone the repository. - The Bonostl library headers are all
.hppheaders, which means you can simply include them in your own projects.
The project supports both CMake and xmake build systems. It requires a C++26 compiler and links libatomic for 16-byte atomics on GCC/Clang.
cmake -B build -G "MinGW Makefiles" -DCMAKE_CXX_COMPILER=g++
cmake --build build
./build/bonostl_benchmark.exe
ctest --test-dir build # run the test suitexmake f --toolchain=gcc
xmake
./build/windows/x64/release/bonostl_benchmark.exe
xmake run bonostl_tests # run the test suiteBoth build systems work inside Visual Studio without changing the toolchain (MinGW GCC is still the compiler in both cases):
- CMake (Open Folder):
File > Open > Folder...on the project root. Visual Studio readsCMakePresets.jsonand offers themingw-debug/mingw-releasepresets for configure, build and test (CTest). - xmake (solution): open
vsxmake2026/Bonostl.slnx. The projects wrap xmake commands, so Build/Rebuild/Clean runxmakeunder the hood. Regenerate after changingxmake.lua:Setxmake project -k vsxmake2026 -m "debug,release" dotnet sln vsxmake2026/Bonostl.sln migrate # upgrade to .slnx
bonostl_benchmark(orbonostl_tests) as the startup project before running — theBonostltarget is a header-only library with no executable.
The test suite uses Catch2 v3 and covers:
- FIFO/LIFO ordering and empty states for all containers
- Concurrent producer/consumer invariants (element counts and value sums)
- Lock-free stack/queue stress tests with multiple threads
- Parallel algorithms verified against their
std::counterparts
- bonostlpch(A dependency of a bunch of files included from C++ standard libraries)
- Containers
- queue (single-threaded; use threadsafe_queue or lockfree_queue for concurrency)
- threadsafe_stack
- threadsafe_queue
- blocking_queue (bounded, blocking push/pop for backpressure)
- threadsafe_lookup_table
- threadsafe_list
- lockfree_stack
- lockfree_queue
- lockfree_list (Harris-Michael ordered set, hazard-pointer reclaimed)
- concurrent_skip_list (lazy skip list; ordered set, epoch-reclaimed)
- lockfree_hash_map (split-ordered list; incremental resize without rehashing)
- Algorithms
- parallel_accumulate
- parallel_find
- parallel_for_each
- parallel_partial_sum
- parallel_quick_sort
- parallel_transform
- parallel_predicates (count_if, all_of, any_of, none_of)
- parallel_scan (inclusive and exclusive prefix sums)
- parallel_merge_sort (stable)
- Locks
- spinlock_mutex
- shared_spinlock (reader-writer spin lock; std::shared_lock compatible)
- seqlock (read-optimistic; readers never block)
- Synchronization (educational; prefer the std equivalents in production)
- counting_semaphore / binary_semaphore (cf. std::counting_semaphore, C++20)
- latch (cf. std::latch, C++20)
- barrier (cf. std::barrier, C++20)
- Utilities
- hazard_ptr (hazard-pointer reclamation helpers for lock-free containers)
- epoch_reclaim (epoch-based reclamation domain for whole-operation protection)
- Thread pool
- function_wrapper (move-only type-erased task wrapper)
- work_stealing_queue
- thread_pool (work-stealing thread pool with per-thread local queues)
Note:
pop-style operations returnstd::optional<T>instead of throwing or returning null pointers.threadsafe_lookup_table::value_foralso returnsstd::optional<Value>.
Bonostl uses MIT License.
MIT License
Copyright (c) 2025 Cle2ment
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
© Cle2ment, 2025