From: Philippe A. Bouchard (philippeb_at_[hidden])
Date: 2002-09-02 21:10:05


Beman Dawes wrote:

[...]

> Greg Colvin's original shared_ptr design, as later extended by Greg and
> Peter Dimov, with help from Darin Adler and other Boosters, has proved to
> be far more versatile than anyone could have imagined when it was first
> proposed ten years ago, particularly when teamed with the other Boost
> smart
> pointers. But policy-based smart pointers may be a better choice for
> those who feel they absolutely must have 100% control over every detail of
> implementation.

I do not know yet the best policy to add. Maybe someone could help. I am
more oriented towards the garbage collector and here is what I am thinking:

Regular garbage collectors do not have a clue when exactly the object
should be destroyed. This is not good news for QT widgets, for example.
Maybe we could mix rc & gc advantages... to determine exactly when the
object's life is terminated with reference counts followed by destruction &
deallocation of the object using some type traits at a given time.

For example:
struct KeepAliveWANServers
{
        ... // Really slow constructor & destructor
};

struct KeepAliveLANServers
{
        ... // Relatively slow constructor & destructor
};

template <>
        struct tree_traits<KeepAliveWANServers>
        {
                typedef simple_tree type;
                typedef process_end destruction_mark;
        };

template <>
        struct tree_traits<KeepAliveLANServers>
        {
                typedef simple_tree type;
                typedef thread_end destruction_mark;
        };

template <>
        struct tree_traits<int>
        {
                typedef simple_tree type;
                typedef ref_end destruction_mark;
        };

Integers shall be destroyed immediately, KeepAliveLANServers at the end of
the thread and KeepAliveWANServers at the end of the process.

We could add swap options, etc.

Philippe A. Bouchard