| 32 | } |
| 33 | |
| 34 | void cancel_at_function_object_test() |
| 35 | { |
| 36 | io_context ioc; |
| 37 | int count = 0; |
| 38 | |
| 39 | steady_timer t(ioc, chronons::milliseconds(100)); |
| 40 | auto now = steady_timer::clock_type::now(); |
| 41 | t.async_wait( |
| 42 | cancel_at(now + chronons::seconds(5), |
| 43 | bindns::bind(&increment_on_cancel, |
| 44 | &count, bindns::placeholders::_1))); |
| 45 | |
| 46 | ioc.run(); |
| 47 | |
| 48 | BOOST_ASIO_CHECK(count == 0); |
| 49 | |
| 50 | t.expires_after(chronons::seconds(5)); |
| 51 | now = steady_timer::clock_type::now(); |
| 52 | t.async_wait( |
| 53 | cancel_at(now + chronons::milliseconds(100), |
| 54 | bindns::bind(&increment_on_cancel, |
| 55 | &count, bindns::placeholders::_1))); |
| 56 | |
| 57 | ioc.restart(); |
| 58 | ioc.run(); |
| 59 | |
| 60 | BOOST_ASIO_CHECK(count == 1); |
| 61 | |
| 62 | t.expires_after(chronons::milliseconds(100)); |
| 63 | now = steady_timer::clock_type::now(); |
| 64 | t.async_wait( |
| 65 | cancel_at(now + chronons::seconds(5), |
| 66 | cancel_at(now + chronons::seconds(10), |
| 67 | bindns::bind(&increment_on_cancel, |
| 68 | &count, bindns::placeholders::_1)))); |
| 69 | |
| 70 | ioc.restart(); |
| 71 | ioc.run(); |
| 72 | |
| 73 | BOOST_ASIO_CHECK(count == 1); |
| 74 | |
| 75 | t.expires_after(chronons::seconds(5)); |
| 76 | now = steady_timer::clock_type::now(); |
| 77 | t.async_wait( |
| 78 | cancel_at(now + chronons::milliseconds(100), |
| 79 | cancel_at(now + chronons::seconds(10), |
| 80 | bindns::bind(&increment_on_cancel, |
| 81 | &count, bindns::placeholders::_1)))); |
| 82 | |
| 83 | ioc.restart(); |
| 84 | ioc.run(); |
| 85 | |
| 86 | BOOST_ASIO_CHECK(count == 2); |
| 87 | |
| 88 | t.expires_after(chronons::seconds(5)); |
| 89 | now = steady_timer::clock_type::now(); |
| 90 | t.async_wait( |
| 91 | cancel_at(now + chronons::seconds(10), |
nothing calls this directly
no test coverage detected