|
Boost Users : |
From: Nat Goodspeed (ngoodspeed_at_[hidden])
Date: 2006-12-01 15:52:19
________________________________________
From: boost-users-bounces_at_[hidden]
[mailto:boost-users-bounces_at_[hidden]] On Behalf Of Gottlob Frege
Sent: Friday, December 01, 2006 3:25 PM
To: boost-users_at_[hidden]
Subject: Re: [Boost-users] boost::weak_ptr and boost::intrusive_ptr
> On 12/1/06, Nat Goodspeed <ngoodspeed at solidworks dot com> wrote:
> > It seems possible to implement weak_ptr notification by building a
list
> > of weak_ptr instances referencing a given object. If we don't want
that
> > list to consume additional heap memory, the list could itself be
> > intrusive in the weak_ptr objects. If we want it to be efficient, we
> > build a doubly-linked list. (This may call for a policy-based
> > implementation so the consumer can decide which overhead is least
> > noxious.)
>
> Interestingly, since you define the intrusive_ptr_add_ref and
> release, you can probably implement the list management without
> changing intrusive_ptr.
[Nat] That's true, you could. But that would impose the requirement on
everyone who wanted to use intrusive_ptr with this new variety of
weak_ptr. Perhaps intrusive_ptr could do something implicit before
calling intrusive_ptr_release.
Maybe that could be implemented as an intrusive_ptr policy.
> Would you prefer to have the list of weak_ptrs kept on the
> intrusive_ptr (on the actual 'intruded' object, actually), or
> have a global map of intrusive_ptr object to weak_ptr list?
[Nat] I was thinking of storing the head pointer in the object itself.
But it might be more consistent with the present intrusive_ptr
implementation to call an intrusive_ptr_get_first_weak_ptr function,
requiring the consumer to decide where to put it.
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net