Lock-free Reference counting and C++ smart pointers
问题 In general, most widely known implementations of reference-counting smart ptr classes in C++, including the standard std::shared_ptr , use atomic reference counting, but do not provide atomic access to the same smart ptr instance. In other words, multiple threads may safely operate on separate shared_ptr instances which point to the same shared object, but multiple threads cannot safely read/write instances of the same shared_ptr instance without providing some kind of synchronization such as