Boost logo

Boost Users :

Subject: [Boost-users] [Asio] Combining use_future with strands
From: Sorin Fetche (sorin.fetche_at_[hidden])
Date: 2018-12-17 06:39:37


Is there a way to combine the special use_future completion token with a
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>,
//________________________________________How to add the strand here ^^^ ?

The code area where I would like to apply this is in this test program:

The self contained program and its output is here:

As a background, the test program I wrote is based on these Boost.Asio
- for strand usage (i.e. bind_executor):

- for composed operations:

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,

Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at