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
of weak_ptr instances referencing a given object. If we don't want
________________________________________ From: boost-users-bounces@lists.boost.org [mailto:boost-users-bounces@lists.boost.org] On Behalf Of Gottlob Frege Sent: Friday, December 01, 2006 3:25 PM To: boost-users@lists.boost.org Subject: Re: [Boost-users] boost::weak_ptr and boost::intrusive_ptr list 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.
participants (1)
-
Nat Goodspeed