Using Quiescent States to Reclaim Memory

1 · Jeff Preshing · July 26, 2016, 10:30 a.m.
If you want to support multiple readers for a data structure, while protecting against concurrent writes, a read-write lock might seem like the only way – but it isn’t! You can achieve the same thing without a read-write lock if you allow several copies of the data structure to exist in memory. You just need a way to delete old copies when they’re no longer in use. Let’s look at one way to achieve that in C++. We’ll start with an example based on a read-write lock. Using a Read-Write Lock Suppos...