| 107 | //------------------------------------------------------------------------------ |
| 108 | |
| 109 | void 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 |
no test coverage detected