From: Christopher Kohlhoff (chris_at_[hidden])
Date: 2005-08-17 07:32:53
--- Pavel Vozenilek <pavel_vozenilek_at_[hidden]> wrote:
> A note aside: David Kohlhoff who
I've been called many things, but never David ;)
> wrote asio library (http://asio.sourceforge.net/)
> also implemented futures on the top
> of his library.
> I am still at trying to understand the whole
> thing so I can offer only pointer.
Just to clarify, asio does not include an implementation of futures.
Instead, I have attached a couple of programs (to which Pavel was
referring) that illustrate how asio might be used to implement them.
Some points of note:
- The demuxer class can easily be used as a thread pool to perform the
work associated with a future (rather than spawning a thread just for a
- A future need not just be used for waiting for the result of a single
long-running function. It could also be used to wait for an
asynchronous operation, or chain of asynchronous operations, to
My personal preference in futures is to have a reference counting
handle->body implementation, where the future class itself would have
little more than operations (or operators) for setting and
You would then have a separate function for creating a new future from
a simple function or composed function object (rather than implicit
conversion from a function object), e.g.
template <typename Functor>
make_future(demuxer& d, Functor f);
Other similar functions could be defined for creating futures that use
a specially spawned thread to do the work, etc. This approach would
also permit the use of futures on their own when needed (such as in the
chain-of-async-operations use case).
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk