Boost logo

Boost :

From: Phil Bouchard (philippe_at_[hidden])
Date: 2008-05-01 05:52:57


"Steven Watanabe" <watanabesj_at_[hidden]> wrote in message
news:48178BBA.3050100_at_providere-consulting.com...

[...]

> I'm thinking that the cleanest solution will be to have set deletion
> split the
> cleanup into first calling all the objects' destructors and then freeing
> all
> the memory. When the objects are destroyed you should increment the
> reference count to make sure that the objects are not destroyed again.
> When you actually release the memory you can then verify that the
> reference
> count is 1, and thus that all references to the object come from within
> the set.
>
> Otherwise, looking at your current implementation, it looks like
> shifted_ptr's
> on the heap will never clean up the object pointed to until the set goes
> away.

Great news...! I just tried it this way and it works perfectly. The set
elements are now following the destruction hierarchy properly which is very
nice. I have changed: set::release() and removed U<T>::po_ = 0 in
shifted_ptr::release() when an element on the heap is being deleted, which
was basically a brute force deletion avoiding recursive problems.

But the sequence order doesn't guarantee the element pointed to by po_ will
be the first to be deleted. I tried different alternatives and ended with
unwanted behaviors so I kept it this way until I work on it again.

The library isn't in the Sandbox yet but should be there quickly enough.

Bests,
-Phil


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