Boost logo

Boost :

From: Greg Colvin (gcolvin_at_[hidden])
Date: 1999-12-04 16:47:08


From: Andy Glew <glew_at_[hidden]>
> > Thoughts?
>
> I like your semantic breakdown:
> strong/weak, non-null/optional null.
>
> It is better than my keepalive/live breakdown,
> because it is more consistent with how I use
> reference counted pointers. I find I don't use
> reference counts to do garbage collection
> - rather, I use reference counts as a debugging
> tool that detects when I am deleting an
> object that still has outstanding references.
>
> This allows you to put useful stuff in your
> destructors - things like releasing locks, etc.
> - knowing that the object will be deleted when
> you say it should be, but also knowing that
> dangling references can be avoided.

With a reference counted pointer like shared_ptr you can
know, by design, when and in what order destructors are
called, and need have no fear of dangling references, even
during destruction.

> You can't do anything useful in a strict GC
> system, because you never know when the
> GC will be called.

That is why I prefer an explicit call to do the collection.
You can automate it with a new_handler if you want, or you
can collect only when you want to. But during collection
you still have to beware of dangling references, since there
is no way to know in what order the nodes of a cycle will be
destroyed, and if it wasn't for cycles you wouldn't need a
collector.

> E.g. Java's finalize methods
> aren't terribly precise.

You can't count on Java finalizers ever being called, so
they are nearly worthless.


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