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

Function test_deferred

example/cpp14/operations/c_callback_wrapper.cpp:187–207  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers 1

mainFunction · 0.70

Calls 2

async_read_inputFunction · 0.70
runMethod · 0.45

Tested by

no test coverage detected