News for hackers. Stuff that matters.
Re:Friendship ended with the garbage collector by BenFrantzDale on Friday August 27, 2021 @08:34AM (#28326993)
Typically unique_ptr is represented as a pointer (check sizeof). For shared_ptr, there’s an atomic refcount but no locks. Operations on the shared_ptr object itself aren’t threadsafe (you can’t have the same shared_ptr assigned by two threads at the same time without locking), just like int, but the reference count is atomic, so copies of shared_ptr can safely be shared among threads. Atomic_shared_ptr adds atomicity to the pointer itself. I believe that usually uses locks.

There are no comments on this comment yet.