| 187 | //------------------------------------------------------------------------------ |
| 188 | |
| 189 | void 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 |
no test coverage detected