Boost logo

Boost :

Subject: Re: [boost] Futures
From: Niall Douglas (s_sourceforge_at_[hidden])
Date: 2015-01-12 10:45:07


On 7 Jan 2015 at 19:56, Vicente J. Botet Escriba wrote:

> Using a Callable (void()) like e.g.
>
> template <class Callable>
> voidFuture::when_ready(Callable&&);

I don't like futures having to store a list of callables to call when
set_value() or set_exception() is called. It means futures must
allocate memory. I think only the wait() call should allocate memory
where possible. After all, when you call wait() on a list of futures,
you expect it to be an expensive operation.

Also, instead of when_ready() it should be when_set() to emphasise it
will be called in the thread setting the state.

How about an API which asks a future to atomically insert itself into
a chain of linked list pointers maintained by the future returned
from the wait() call? That lets the source future get destroyed
without having its shared state linger or indeed having any shared
state at all, and the unlink operation ought to be very fast. The
destination future coming out of a wait_for_all() or wait_for_any() I
think can never avoid being a big and fat future, especially if it
accepts heterogeneous future types.

Niall

-- 
ned Productions Limited Consulting
http://www.nedproductions.biz/ 
http://ie.linkedin.com/in/nialldouglas/



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