$include_dir="/home/hyper-archives/boost-users/include"; include("$include_dir/msg-header.inc") ?>
Subject: Re: [Boost-users] [boost::asio] Wait for multiple async_read()'s
From: Gavin Lambert (gavinl_at_[hidden])
Date: 2017-01-22 17:58:05
On 22/01/2017 01:09, Adam Zegelin wrote:
> One solution I've found, though it feels "un-asio" is to pass the
> use_future option as the hander for the reads. The result is futures
> for each read, which I can then place into a list<future>, and have an
> additional io_service.post()'ed handler call get() on these futures.
> The only issue with this is that I must call io_service.run() from
> more than one thread, since the handler calling get() blocks â
> otherwise I can potentially deadlock the whole application.
You can pass a collection of futures to when_all(), which returns a
future that will be completed when all the parameters are completed.
You can then use future.then() to attach a continuation to this future
which will execute when that occurs.