Assume we have a std::shared_ptr<int> sptr
in thread1;
Thread 1 return and trigger destructor of sptr
;
By the mean time thread2 called a constructor to copy sptr
;
How could std::shared_ptr
in multi-thread with a single atomic could guareente that this code would not crush in this race condition?
Aucun commentaire:
Enregistrer un commentaire