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_one
ornotify_all
member function. Typically, a valuelessset_value
call is used to ...
Add a Comment
Comments are closed.