Home > database >  Is shared_ptr<void>::reset() lock-free?
Is shared_ptr<void>::reset() lock-free?

Time:09-26

Imagine the following:

// SECTION A
MyClass* object = new MyClass();
std::shared_ptr<void> sharedObject;

// SECTION B (sharedObject is empty)
sharedObject.reset(object);

Is section B lock-free for an empty sharedObject? Or does it depend of the implementation?

CodePudding user response:

This depends on implementation.

Some pointers:

  1. Overhead and implementation of using shared_ptr
  2. Linking pthread disables lock-free shared_ptr implementation
  • Related