Boost logo

Boost :

From: Andrew J Bromage (ajb_at_[hidden])
Date: 2002-08-06 21:49:33

G'day all.

On Tue, Aug 06, 2002 at 08:28:49PM -0500, Rene Rivera wrote:

> Hmmm, maybe I missed something but... If it's singleton type data why not
> make it static?

I want it for nonstatic data. Here's what I want to be able to write:

    // Disclaimer: The following code is untested and
    // non-const-correct for brevity.

    class something
        const expensive_data&
            return *m_expensive;

        something(const other_data& other)
            : m_other(other)

        boost::once m_once;
        std::auto_ptr<expensive_data> m_expensive;

        other_data m_other;

            m_expensive = new expensive_data(m_other);

Moreover (and this is what makes it tricky), I want to do it with as
little mutex contention as possible. In particular I want to avoid
obtaining a lock when get_expensive() is called after the expensive
data has been created.

Andrew Bromage

Boost list run by bdawes at, gregod at, cpdaniel at, john at