Boost logo

Boost :

Subject: Re: [boost] Futures Review - minor implementation details
From: Anthony Williams (anthony.ajw_at_[hidden])
Date: 2009-01-20 06:40:44


"vicente.botet" <vicente.botet_at_[hidden]> writes:

> 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?

These are the constructors. The "future" member is initially NULL, so
the swap sets "other.future" to NULL whilst transferring the value
from "other.future" to "this->future"

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

The former avoids incrementing any reference counts. The
latter has to increase the reference count on *other.future just to
decrease it again with the reset.

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

Yes.

Anthony

-- 
Anthony Williams            | Just Software Solutions Ltd
Custom Software Development | http://www.justsoftwaresolutions.co.uk
Registered in England, Company Number 5478976.
Registered Office: 15 Carrallack Mews, St Just, Cornwall, TR19 7UL

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