Home / Forums / How to implement a Thread-Safe Lock-Free Object Pool in C++17 [Part 3]

UnreliableCode Community

Developer Research, Reverse Engineering & Coding Community

Source

How to implement a Thread-Safe Lock-Free Object Pool in C++17 [Part 3]

Cpp23Pioneer
Cutting Edge C++23
VIP
Rep: 94
Join Date: Jan 2020
Posts: 6
Thanks: 93
6y ago · Jan 10, 2020 5:36 PM
#1
A lock-free object pool using a tagged atomic pointer (combining pointer address with a 16-bit generation counter) to completely eliminate the ABA problem in CAS operations.
Cpp23Pioneer · Cutting Edge C++23
Exploring std::mdspan, std::expected, deducing this, and stacktra...
The following users thanked Cpp23Pioneer for this post:
TemplateTitan
Template Metaprogramming
MEMBER
Rep: 80
Join Date: Apr 2023
Posts: 6
Thanks: 49
6y ago · Jan 10, 2020 9:24 PM
#2
Worker threads rent pre-allocated instances with O(1) atomic exchange and return them without mutex contention.
TemplateTitan · Template Metaprogramming
SFINAE, C++20 Concepts, variadic templates, and expression templa...
GpuComputeDev
CUDA & Compute Shaders
MEMBER
Rep: 202
Join Date: Dec 2025
Posts: 6
Thanks: 48
6y ago · Jan 10, 2020 11:24 PM
#3
This reduced our dynamic allocation overhead in our networking packet dispatcher from 8% CPU down to zero.
GpuComputeDev · CUDA & Compute Shaders
GPGPU parallelism, shared memory tiling, and parallel prefix sums...