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:


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.

Attachments (0)

Change History (0)

Modify Ticket

Change Properties
Set your email in Preferences
as new The owner will remain Peter Dimov.

Add Comment

E-mail address and name can be saved in the Preferences.

Note: See TracTickets for help on using tickets.