Entries by Rainer Grimm

Read-copy-update (RCU)

Read-copy-update is strong in multithreading environments where a data structure is read almost exclusively but rarely written. First of all, what is RCU? The excellent Wikipedia page on Read-copy-update provides a good introduction: In computer science, read-copy-update (RCU) is a synchronization mechanism that avoids the use of lock primitives while multiple threads concurrently read and […]

atomic<shared_ptr<>> by Oliver Schädlich

This blog article is an experiment. A few days ago, I received the following email (translated from German) from Oliver Schädlich (oliver.schaedlich@gmail.com). If, as I hope, this article sparks a discussion, I will be happy to summarize it in my last article. Please send an email to: Rainer.Grimm@ModernesCpp.de. I just read your latest article on […]

My ALS Journey (23/n): Cippi

Let me introduce Cippi. I hope you like her. You probably already know her from my C++ books. >> My ALS Journey so far << Cippi I’m Cippi: curious, clever, and—yes—feminine! You’re probably wondering why I’m mentioning Cippi here. The reason is simple. Since I can no longer attend C++ conferences myself, I will be […]

Hazard Pointers in C++26

Hazard pointers provide garbage collection in C++ and solve the ABA problem. First of all. What is a hazard pointer? Proposal P2530R3 gives a nice explanation: A hazard pointer is a single-writer multi-reader pointer that can be owned by at most one thread at any time. Only the owner of the hazard pointer can set […]

My ALS Journey (22/n): Call for Collaboration

Today, I have a special call for collaboration. >> My ALS Journey so far << My Challenge My writing skills are very poor, but my speaking is pretty good. I use my voice to write articles or programs. Dictating is very cumbersome and error-prone, and it takes four times as long to write a blog […]

A Lock-Free Stack: A Hazard Pointer Implementation Explained II

In my last post, I started to explain a hazard pointer implementation: A Lock-Free Stack: A Hazard Pointer Implementation Explained I. Today, I will continue to explain the implementation. The Retire List The retire list has the public member functions isInUse, addNode, and deleteUnusedNodes. Additionally, it has the inner class RetireNode, an atomic member of […]

A Lock-Free Stack: A Hazard Pointer Implementation Explained I

In my last post, I presented a hazard pointer implementation: A Lock-Free Stack: A Hazard Pointer Implementation. Today, I will explain the implementation. MyNode is a class template, parametrized by the type it holds: data. MyNode models the concept Node. template <typename T> concept Node = requires(T a) { {T::data}; { *a.next } -> std::same_as<T&>; […]

My ALS Journey (21/n): ALS Fundraiser by Jen and Jason

Today, I want to present you something special. >> My ALS Journey so far << ALS Fundraiser by Jen and Jason https://x.com/lefticus/status/1895996735610032400 I cannot express how happy I am to have such friends! Jen and Jason, have a good journey. From one Week to two Weeks You may have already noticed. I will change my […]

A Lock-Free Stack: A Hazard Pointer Implementation

Hazard Pointers solve all issues of the previous implementation: A Lock-Free Stack: A Simple Garbage Collector. From one Week to two Weeks You may have already noticed. I will change my blog publishing frequency from one to two weeks in the future. Writing a post using your voice is exceptionally exhausting and time-consuming. Hazard Pointers […]

A Lock-Free Stack: A Simple Garbage Collector

My next lock-free stack includes a simple garbage collector. I discussed the concurrent execution of more than one topAndPush call is a Race Condition. I can safely delete a node if not more than one topAndPush call is executing concurrently. This observation is crucial for solving this memory leak issue: I store removed nodes on […]