Opened 6 years ago

#7125 new Feature Requests

weak_ptr::lock() thread safety

Reported by: Gennady Proskurin <gpr@…> Owned by: Peter Dimov
Milestone: To Be Determined Component: smart_ptr
Version: Boost 1.50.0 Severity: Problem
Keywords: Cc:

Description

Imagine the following code:

shared_ptr<T> sp(new ...);
weak_ptr<T> wp(sp);

sp.reset(); // thread A
shared_ptr<T> sp1 = wp.lock(); // thread B

It is not clear from documentation, whether it is safe to call shared_ptr::reset() and weak_ptr::lock() concurrently in different threads. It is very frequently asked question and should be documented explicitly.

Change History (0)

Note: See TracTickets for help on using tickets.