3 ms·
std::shared_ptr doesn't use mutexes in any implementation I know of. They use atomic instructions for incrementing and decrementing the reference count, which a
by tlb 4y ago
std::shared_ptr doesn't use mutexes in any implementation I know of. They use atomic instructions for incrementing and decrementing the reference count, which are very fast.
- intelVISA 4y agoPlus their thread-safety is limited to the pointer's control block not the actual object it's pointing to. e: nvm reading hard brain mutex too slow
- another_another 4y agoYou're right, an atomic inc/dec would also do just fine. I stand corrected.