1. 5
  1.  

    1. 1

      The problem is not with “sharing objects between threads”, rather “sharing references to objects between threads.”

      That is, it’s about allowing multiple threads to concurrently mutate a single strong reference to an object.

      Another solution to this is don’t do that. The C++ codebase I work on uses ref-counting (using a homemade library, not std), and we don’t allow a Retained<T> instance to be concurrently mutated. Instead we pass them by copy between threads when necessary.

      I know there’s an atomic_shared_ptr coming in C++26 but I don’t know how it works internally.