Boost logo

Boost Users :

Subject: Re: [Boost-users] [boost::asio] Wait for multiple async_read()'s
From: Adam Zegelin (adam_at_[hidden])
Date: 2017-01-24 17:47:11


Thanks for everyones suggestions.

On Mon, Jan 23, 2017 at 9:58 AM, Gavin Lambert <gavinl_at_[hidden]> wrote:

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

That's exactly what I was looking for, thank you!

I swear I read the docs for boost::future multiple times, but it looks
like its a fairly recent addition to the library (labeled
experimental).
Google has this tendency to link to older documentation sets (this
always gets me when googling for postgres docs) and I probably Googled
boost::future and ended up reading the docs from 20 years ago!
Hint to boost devs: do what postgres does and have a link to the most
recent doc version at the top of every page.

On Sun, Jan 22, 2017 at 1:31 AM, TONGARI J <tongari95_at_[hidden]> wrote:
> Coroutine may help. Take a simple echo-server for example:
> https://github.com/jamboree/co2#asio-echo-server
> In your case, you just need to keep the tasks in a list and 'await' for them
> to complete.

I looked into co-routines but they seem like too much magic for my taste.
Perhaps in a future project.

On Sat, Jan 21, 2017 at 11:24 PM, Maarten de Vries <maarten_at_[hidden]> wrote:
> I would definitely go with this approach. It's by far the simplest and to me
> it seems to match an asynchronous philosophy pretty well.

I got this to work, but it seems like a lot of work at every "join" point.
Not to mention it combines the concerns of the upstream and downstream
read-handlers — upstream has to know about downstream.

Regards,
Adam


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net