Boost logo

Boost :

From: William E. Kempf (wekempf_at_[hidden])
Date: 2003-01-07 13:11:51


> From: "Peter Dimov" <pdimov_at_[hidden]>
> From: "William E. Kempf" <wekempf_at_[hidden]>
> > > No, the user would not be expected to do any bookkeeping. He would only
> need
> > > to call find_unreachable_objects() that would return a list of the
> > > unreachable objects, and then, optionally, call break_cycles() with that
> > > list as an argument. Or something like that. :-)
> >
> > And how would break_cycles() accomplish its task with out book keeping?
>
> The information that is needed to break the cycles (a list of unreachable
> shared_ptr instances) is generated by find_unreachable_objects for free,
> since to determine object reachability, objects are scanned for shared_ptr
> subobjects. When those shared_ptrs are reset() by break_cycles(), all
> unreachable objects will be freed, their destructors will run, and any
> weak_ptrs to those objects will correctly expire.

I don't follow this. How does the user prevent the destructors from referencing the other object(s) participating in the cycle which may no longer exist? The only safe way to break the cycle is to have intimate knowledge about the objects participating in the cycle and do what ever clean up is required in a determistic manner *before* the object's are destroyed and the memory is freed.

William E. Kempf
wekempf_at_[hidden]


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk