How am I supposed to implement value-semantics for multi-threaded environment without synchronization?

The check performed by isKnownUniquelyReferenced is meaningful as long as the reference pointing to the storage is accessible only from one thread. If the storage itself is available to another thread via another reference, that's fine as isKnownUniquelyReferenced will simply return false in that case. Only if the reference itself is shared between threads do you need synchronizing access to the reference.

1 Like