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:

The self contained program and its output is here:


As a background, the test program I wrote is based on these Boost.Asio examples:

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