Lock-free swap of two unique_ptr
The idiomatic way to modify two variables atomically is to use a lock. You can’t do it for std::unique_ptr without a lock. Even std::atomic<int> doesn’t provide a way to swap two values atomically. You can update one atomically and get its previous value back, but a swap is conceptually three steps, in terms of the … Read more