| 168 | }; |
| 169 | |
| 170 | void any_completion_handler_associator_test() |
| 171 | { |
| 172 | typedef boost::asio::any_completion_handler<void()> handler_type; |
| 173 | |
| 174 | int count = 0; |
| 175 | int alloc_count = 0; |
| 176 | int cancel_count = 0; |
| 177 | boost::asio::thread_pool pool(1); |
| 178 | boost::asio::cancellation_signal sig; |
| 179 | |
| 180 | boost::asio::any_completion_handler<void()> h1( |
| 181 | boost::asio::bind_allocator(handler_allocator<char>(&alloc_count), |
| 182 | boost::asio::bind_cancellation_slot(sig.slot(), |
| 183 | boost::asio::bind_executor(pool.get_executor(), |
| 184 | boost::asio::bind_immediate_executor(boost::asio::inline_executor(), |
| 185 | bindns::bind(&increment, &count)))))); |
| 186 | |
| 187 | BOOST_ASIO_CHECK(alloc_count == 1); |
| 188 | |
| 189 | BOOST_ASIO_REBIND_ALLOC(boost::asio::associated_allocator<handler_type>::type, |
| 190 | char) alloc1(boost::asio::get_associated_allocator(h1)); |
| 191 | alloc1.deallocate(alloc1.allocate(1), 1); |
| 192 | |
| 193 | BOOST_ASIO_CHECK(alloc_count == 2); |
| 194 | |
| 195 | boost::asio::associated_cancellation_slot<handler_type>::type slot1 |
| 196 | = boost::asio::get_associated_cancellation_slot(h1); |
| 197 | |
| 198 | BOOST_ASIO_CHECK(slot1.is_connected()); |
| 199 | |
| 200 | slot1.emplace<cancel_handler>(&cancel_count); |
| 201 | |
| 202 | BOOST_ASIO_CHECK(cancel_count == 0); |
| 203 | |
| 204 | sig.emit(boost::asio::cancellation_type::terminal); |
| 205 | |
| 206 | BOOST_ASIO_CHECK(cancel_count == 1); |
| 207 | |
| 208 | boost::asio::associated_executor<handler_type>::type ex1 |
| 209 | = boost::asio::get_associated_executor(h1); |
| 210 | |
| 211 | BOOST_ASIO_CHECK(ex1 == pool.get_executor()); |
| 212 | |
| 213 | boost::asio::associated_immediate_executor< |
| 214 | handler_type, boost::asio::thread_pool::executor_type>::type ex2 |
| 215 | = boost::asio::get_associated_immediate_executor(h1, pool.get_executor()); |
| 216 | |
| 217 | BOOST_ASIO_CHECK(ex2 == boost::asio::inline_executor()); |
| 218 | } |
| 219 | |
| 220 | void increment_with_error(boost::system::error_code ec, |
| 221 | boost::system::error_code* out_ec, int* count) |
nothing calls this directly
no test coverage detected