Boost logo

Boost :

Subject: Re: [boost] Futures Review - minor implementation details
From: vicente.botet (vicente.botet_at_[hidden])
Date: 2009-01-06 17:13:37


Hi Anthony,

Some minor implementation details:
Why there is not other.future reset in
        shared_future(shared_future && other)
        {
            future.swap(other.future);
        }
        shared_future(unique_future<R> && other)
        {
            future.swap(other.future);
        }

How the move is made?

Is
            future.swap(other.future);
            other.future.reset();
more efficient than
            future.reset(other.future);
            other.future.reset();
? Otherwise you can change it in:

        shared_future& operator=(shared_future && other)
        {
            future.swap(other.future);
            other.future.reset();
            return *this;
        }
        shared_future& operator=(boost::detail::thread_move_t<shared_future> other)
        {
            future.swap(other->future);
            other->future.reset();
            return *this;
        }
        shared_future& operator=(boost::detail::thread_move_t<unique_future<R> > other)
        {
            future.swap(other->future);
            other->future.reset();
            return *this;
        }

And once shared_ptr implements movable you could use
    future = move(other.future);
Isn't it?

Vicente


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