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

Function test_deferred

example/cpp20/operations/c_callback_wrapper.cpp:189–209  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

187//------------------------------------------------------------------------------
188
189void test_deferred()
190{
191 boost::asio::io_context io_context;
192
193 // Test our asynchronous operation using the deferred completion token. This
194 // token causes the operation's initiating function to package up the
195 // operation with its arguments to return a function object, which may then be
196 // used to launch the asynchronous operation.
197 auto op = async_read_input("Enter your name", boost::asio::deferred);
198
199 // Launch our asynchronous operation using a lambda as a callback. We will use
200 // an io_context to obtain an associated executor.
201 std::move(op)(
202 boost::asio::bind_executor(io_context,
203 [](const std::string& result)
204 {
205 std::cout << "Hello " << result << "\n";
206 }));
207
208 io_context.run();
209}
210
211//------------------------------------------------------------------------------
212

Callers 1

mainFunction · 0.70

Calls 2

async_read_inputFunction · 0.70
runMethod · 0.45

Tested by

no test coverage detected