Listing 5: Two implementations of LockPolicy

template <class Target>
class NoLocking
{
public:
    struct Lock
    {
        Lock() {}
        Lock(const Target&) {}
    };

    typedef Target    VolatileType;
};

template <class Target>
class MutexLocking
{
public:
    class Lock;
    friend class Lock;

    class Lock
    {
    public:
        Lock() : lock_(mtx_)    {}
        Lock(Target&) : lock_(mtx_)    {}
    private:
        boost::mutex::scoped_lock    lock_;
    };

    typedef volatile Target VolatileType;

private:
    static boost::mutex    mtx_;
};