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

Function test_deferred

example/cpp14/operations/callback_wrapper.cpp:109–129  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers 1

mainFunction · 0.70

Calls 2

async_read_inputFunction · 0.70
runMethod · 0.45

Tested by

no test coverage detected