Boost logo

Boost Users :

Subject: Re: [Boost-users] [Asio] Combining use_future with strands
From: Richard Hodges (hodges.r_at_[hidden])
Date: 2018-12-17 07:51:53


I've been discussing a very similar thing with Vinnie Falco, here:
https://github.com/boostorg/beast/issues/1366

On Mon, 17 Dec 2018 at 13:39, Sorin Fetche via Boost-users <
boost-users_at_[hidden]> wrote:

> Hi,
>
> Is there a way to combine the special use_future completion token with a
> strand?
> Something with the meaning of:
> - the asynchronous operation should pass the result to the future it
> returns, and
> - the internal operations of it (if any) should run in a strand
>
> Code snippet:
> asio::io_context io_context;
> asio::io_context::strand strand(io_context);
> std::future<void> f = async_my_operation(io_context, <params>,
> asio::use_future);
> //________________________________________How to add the strand here ^^^ ?
>
>
> The code area where I would like to apply this is in this test program:
>
> https://github.com/sorf/cpp-dev-new/blob/abf9d831a0b82fb81751eee6cfa498d3b982505a/source/test/error_testing/asio_composed.cpp#L259
>
> The self contained program and its output is here:
> https://wandbox.org/permlink/pF5Hbm6jqPOmEKbO
>
>
> As a background, the test program I wrote is based on these Boost.Asio
> examples:
> - for strand usage (i.e. bind_executor):
> https://github.com/boostorg/asio/blob/develop/example/cpp03/tutorial/timer5/timer.cpp
>
> - for composed operations:
> https://github.com/boostorg/asio/blob/develop/example/cpp11/operations/composed_5.cpp
>
> and implements a composed operation that runs multiple internal operations
> in parallel and in series. Similar to the constructor of a socket or a
> timer object, the operation receives as a parameter an io_context; it
> doesn't offer an overload that receives a strand object directly.
>
> The operation is then tested with callback completion, callback completion
> in a strand, future and future + strand (where the test fails).
>
> Thank you,
> Sorin
>
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> https://lists.boost.org/mailman/listinfo.cgi/boost-users
>

-- 
Richard Hodges
hodges.r_at_[hidden]
office: +442032898513
home: +376841522
mobile: +376380212 (this will be *expensive* outside Andorra!)
skype: madmongo
facebook: hodges.r


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