Subject: Re: [boost] Futures vs async_result
From: Michael Caisse (mcaisse-lists_at_[hidden])
Date: 2015-07-27 03:54:55
On 07/24/2015 10:47 AM, Niall Douglas wrote:
<snip the explanation>
> So tl;dr the reason why futures are more appropriate for AFIO is
> because it's easier to specify ordering of operations with future
> continuations because they always flow in sequence from start to end.
> You can do it with ASIO callback handlers too, but it requires more
> typing, and I think is more error prone and harder for other
> programmers to understand.
> The key thing I think those who advocate async_result don't realise
> is you very rarely are adjusting a single file from a single thread
> if you are bothering with async file i/o. In the real world, almost
> certainly multiple threads and processes are all contending on the
> same shared dataset, and you need fine grained control over exactly
> when you do reads and writes with respect to one another.
> Hopefully this answer the question?
Thank you for the great explanation. You were saying async_result, I
repeated async_result, but I kept thinking completion handlers :-/
Fail on my part. Makes much more sense now.
I would highly recommend putting this information somewhere in your
documentation. In some ways it is the motivation.
Future continuations are fine when the sequence from start to end
doesn't branch. I am cautious of their usefulness in the general case
still. It isn't uncommon to make choices in a completion handler to
queue different async actions with different completion handlers.
Thank you for taking the time.
-- Michael Caisse ciere consulting ciere.com
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk