Boost logo

Boost Users :

From: Gottlob Frege (gottlobfrege_at_[hidden])
Date: 2006-12-01 15:25:13


On 12/1/06, Nat Goodspeed <ngoodspeed_at_[hidden]> 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.

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?

ie

void intrusive_ptr_release(MyPointer *p)
{
   decr_refcount(p);

   if (refcount(p) == 0)
   {
      weak_ptr_list weaklist = ??? // where does the list come from? from
p? global?

      for_each_weak_ptr_notify_object_gone(weaklist);

      delete p;
   }

}

Tony



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