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

Function test_deferred

example/cpp20/operations/callback_wrapper.cpp:111–131  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

109//------------------------------------------------------------------------------
110
111void test_deferred()
112{
113 boost::asio::io_context io_context;
114
115 // Test our asynchronous operation using the deferred completion token. This
116 // token causes the operation's initiating function to package up the
117 // operation with its arguments to return a function object, which may then be
118 // used to launch the asynchronous operation.
119 auto op = async_read_input("Enter your name", boost::asio::deferred);
120
121 // Launch our asynchronous operation using a lambda as a callback. We will use
122 // an io_context to obtain an associated executor.
123 std::move(op)(
124 boost::asio::bind_executor(io_context,
125 [](const std::string& result)
126 {
127 std::cout << "Hello " << result << "\n";
128 }));
129
130 io_context.run();
131}
132
133//------------------------------------------------------------------------------
134

Callers 1

mainFunction · 0.70

Calls 2

async_read_inputFunction · 0.70
runMethod · 0.45

Tested by

no test coverage detected