| 92 | } |
| 93 | |
| 94 | void inline_or_executor_execute_test() |
| 95 | { |
| 96 | io_context ioc; |
| 97 | inline_or_executor<io_context::executor_type> s1 = inline_or(ioc); |
| 98 | int count = 0; |
| 99 | |
| 100 | s1.execute(bindns::bind(increment, &count)); |
| 101 | |
| 102 | // Handler is run inline. |
| 103 | BOOST_ASIO_CHECK(count == 1); |
| 104 | |
| 105 | count = 0; |
| 106 | boost::asio::require(s1, boost::asio::execution::blocking.possibly).execute( |
| 107 | bindns::bind(increment, &count)); |
| 108 | |
| 109 | // Handler is run inline. |
| 110 | BOOST_ASIO_CHECK(count == 1); |
| 111 | |
| 112 | count = 0; |
| 113 | boost::asio::require(s1, boost::asio::execution::blocking.never).execute( |
| 114 | bindns::bind(increment, &count)); |
| 115 | |
| 116 | // No handlers can be called until run() is called. |
| 117 | BOOST_ASIO_CHECK(!ioc.stopped()); |
| 118 | BOOST_ASIO_CHECK(count == 0); |
| 119 | |
| 120 | ioc.run(); |
| 121 | |
| 122 | // The run() call will not return until all work has finished. |
| 123 | BOOST_ASIO_CHECK(ioc.stopped()); |
| 124 | BOOST_ASIO_CHECK(count == 1); |
| 125 | |
| 126 | count = 0; |
| 127 | ioc.restart(); |
| 128 | BOOST_ASIO_CHECK(!ioc.stopped()); |
| 129 | |
| 130 | boost::asio::require(s1, |
| 131 | boost::asio::execution::blocking.never, |
| 132 | boost::asio::execution::outstanding_work.tracked |
| 133 | ).execute(bindns::bind(increment, &count)); |
| 134 | |
| 135 | // No handlers can be called until run() is called. |
| 136 | BOOST_ASIO_CHECK(!ioc.stopped()); |
| 137 | BOOST_ASIO_CHECK(count == 0); |
| 138 | |
| 139 | ioc.run(); |
| 140 | |
| 141 | // The run() call will not return until all work has finished. |
| 142 | BOOST_ASIO_CHECK(ioc.stopped()); |
| 143 | BOOST_ASIO_CHECK(count == 1); |
| 144 | |
| 145 | count = 0; |
| 146 | ioc.restart(); |
| 147 | boost::asio::require(s1, |
| 148 | boost::asio::execution::blocking.never, |
| 149 | boost::asio::execution::outstanding_work.untracked |
| 150 | ).execute(bindns::bind(increment, &count)); |
| 151 | |