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

UnreliableCode Community

Developer Research, Reverse Engineering & Coding Community

Source

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

FiberRunner
User-Mode Scheduling
MEMBER
Rep: 104
Join Date: Mar 2022
Posts: 6
Thanks: 15
2y ago · May 22, 2024 6:16 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.
FiberRunner · User-Mode Scheduling
Fiber context switching, cooperative multitasking, and green thre...
The following users thanked FiberRunner for this post:
BytecodeDev
Virtual Machine Author
MEMBER
Rep: 103
Join Date: Aug 2021
Posts: 6
Thanks: 59
2y ago · May 22, 2024 9:56 PM
#2
Worker threads rent pre-allocated instances with O(1) atomic exchange and return them without mutex contention.
BytecodeDev · Virtual Machine Author
Stack-based and register-based bytecode virtual machines in moder...
PointerGuru
Systems & Memory Engineer
MEMBER
Rep: 209
Join Date: Feb 2021
Posts: 6
Thanks: 107
2y ago · May 23, 2024 12:56 AM
#3
This reduced our dynamic allocation overhead in our networking packet dispatcher from 8% CPU down to zero.
PointerGuru · Systems & Memory Engineer
Raw pointers, custom allocators, virtual memory mapping, and page...