| 324 | }; |
| 325 | |
| 326 | void deadline_timer_custom_allocation_test() |
| 327 | { |
| 328 | static boost::asio::io_context io_context; |
| 329 | struct timer |
| 330 | { |
| 331 | boost::asio::deadline_timer t; |
| 332 | timer() : t(io_context) {} |
| 333 | } timers[100]; |
| 334 | |
| 335 | int allocation_count = 0; |
| 336 | |
| 337 | for (int i = 0; i < 50; ++i) |
| 338 | { |
| 339 | timers[i].t.expires_at(boost::posix_time::pos_infin); |
| 340 | timers[i].t.async_wait(custom_allocation_timer_handler(&allocation_count)); |
| 341 | } |
| 342 | |
| 343 | for (int i = 50; i < 100; ++i) |
| 344 | { |
| 345 | timers[i].t.expires_at(boost::posix_time::neg_infin); |
| 346 | timers[i].t.async_wait(custom_allocation_timer_handler(&allocation_count)); |
| 347 | } |
| 348 | |
| 349 | for (int i = 0; i < 50; ++i) |
| 350 | timers[i].t.cancel(); |
| 351 | |
| 352 | io_context.run(); |
| 353 | |
| 354 | BOOST_ASIO_CHECK(allocation_count == 0); |
| 355 | } |
| 356 | |
| 357 | void io_context_run(boost::asio::io_context* ioc) |
| 358 | { |
nothing calls this directly
no test coverage detected