Topics / Coding: Concurrency Primitives / Q12
How do you implement a lock-free stack?
Use atomic compare-and-swap on the head pointer with safe memory reclamation, such as hazard pointers, to prevent use-after-free and ABA hazards.
Use atomic compare-and-swap on the head pointer with safe memory reclamation, such as hazard pointers, to prevent use-after-free and ABA hazards.