Dealing with Mutation: Guarded Suspension -- Rainer Grimm
Guarded Suspension applies a unique strategy to deal with mutation. It signals when it is done with its modification.
Dealing with Mutation: Guarded Suspension
by Rainer Grimm
From the article:
The guarded suspension basic variant combines a lock and a precondition that must be satisfied. If the precondition is not fulfilled, that checking thread puts itself to sleep. The checking thread uses a lock to avoid a race condition that may result in a data race or a deadlock.
Various variants of the Guarded Suspension exist:
- The waiting thread can passively be notified about the state change or actively ask for the state change. In short, I call this push versus pull principle.
- The waiting can be done with or without a time boundary.
- The notification can be sent to one or all waiting threads.
I present in this post only the rough idea. Let me start with the push principle.
You often synchronize threads with a condition variable or a future/promise pair. The condition variable or the promise sends the notification to the waiting thread. A promise has no
notify_oneornotify_allmember function. Typically, a valuelessset_valuecall is used to ...

Recently, our team at Meteksan Defense is upgrading its development environment to use newer versions of many tools and programming languages. One of the more difficult transitions has been the upgrade of our C++11 code base to C++17 for our embedded applications.
Suppose you want to write a template function that accepts any specialization of
I continue my journey with concurrency patterns in today's post. The Thread-Safe Interface fits very well when the critical sections are just objects.
Fold expressions exist in C++ since C++17 and significantly affect how we treat variadic templates. Back in the day, I wrote about
Locking is a straightforward idea to protect a critical section. A critical section is a section of code that, at most, one thread can use at any time.
C++ allows us to declare various forms of non-local objects: they usually live throughout the execution of the whole program. In this article, we’ll look at global variables, dynamic, and thread-local objects. We’ll also consider new features for safe initialization C++20.