MCPcopy Create free account
hub / github.com/boostorg/asio / main

Function main

example/cpp11/parallel_group/ranged_wait_for_all.cpp:18–57  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

16#ifdef BOOST_ASIO_HAS_POSIX_STREAM_DESCRIPTOR
17
18int main()
19{
20 boost::asio::io_context ctx;
21
22 boost::asio::posix::stream_descriptor out(ctx, ::dup(STDOUT_FILENO));
23 boost::asio::posix::stream_descriptor err(ctx, ::dup(STDERR_FILENO));
24
25 using op_type = decltype(
26 out.async_write_some(boost::asio::buffer("", 0))
27 );
28
29 std::vector<op_type> ops;
30
31 ops.push_back(
32 out.async_write_some(boost::asio::buffer("first\r\n", 7))
33 );
34
35 ops.push_back(
36 err.async_write_some(boost::asio::buffer("second\r\n", 8))
37 );
38
39 boost::asio::experimental::make_parallel_group(ops).async_wait(
40 boost::asio::experimental::wait_for_all(),
41 [](
42 std::vector<std::size_t> completion_order,
43 std::vector<boost::system::error_code> ec,
44 std::vector<std::size_t> n
45 )
46 {
47 for (std::size_t i = 0; i < completion_order.size(); ++i)
48 {
49 std::size_t idx = completion_order[i];
50 std::cout << "operation " << idx << " finished: ";
51 std::cout << ec[idx] << ", " << n[idx] << "\n";
52 }
53 }
54 );
55
56 ctx.run();
57}
58
59#else // defined(BOOST_ASIO_HAS_POSIX_STREAM_DESCRIPTOR)
60int main() {}

Callers

nothing calls this directly

Calls 6

bufferFunction · 0.85
wait_for_allClass · 0.85
async_write_someMethod · 0.45
async_waitMethod · 0.45
sizeMethod · 0.45
runMethod · 0.45

Tested by

no test coverage detected