|
Boost : |
From: Darin Adler (darin_at_[hidden])
Date: 2002-02-11 12:14:03
On 2/11/02 9:07 AM, "Peter Dimov" <pdimov_at_[hidden]> wrote:
> From: "Darin Adler" <darin_at_[hidden]>
>> If the current implementation really doesn't work multi-threaded, then
>> perhaps we should bite the bullet and:
>>
>> 1) change documentation to say weak_ptr doesn't work with multiple
>> threads
>> 2) change weak_ptr interface so you make a shared_ptr from it, and
>> remove other operations like *, get(), and ->
>
> If we do (1), there is no need to remove the other operations. They are
> perfectly safe in single threaded programs.
>
> If we have to bite the bullet, we should do (2) and make it work with
> multiple threads. How to do that without penalizing shared_ptr users that
> don't use weak_ptr is not yet clear to me, though.
There are two reasons to do (2) even if we do (1).
a) We don't have to change the programming interface later when we
provide a thread safe version.
b) We add the much-requested feature of being able to create a
shared_ptr from a weak_ptr, which enables use of weak_ptr objects for things
like caches.
I think these are significant benefits.
-- Darin
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk