I analyze a class with unique_ptr member. That member may be used from different threads. There is also a method which destroys that member:
void uninitialize()
{
std::unique_ptr<Worker> worker;
{
std::lock_guard<std::mutex> guard(mtx_);
worker = std::move(worker_);
}
}
I wonder what is purpose of that impl. Is there any difference between the above and the following implementation? :
void uninitialize()
{
std::lock_guard<std::mutex> guard(mtx_);
worker_.reset();
}
Aucun commentaire:
Enregistrer un commentaire