| 100 | } |
| 101 | |
| 102 | void cancel_at_timer_function_object_test() |
| 103 | { |
| 104 | io_context ioc; |
| 105 | steady_timer cancellation_timer1(ioc); |
| 106 | steady_timer cancellation_timer2(ioc); |
| 107 | int count = 0; |
| 108 | |
| 109 | steady_timer t(ioc, chronons::milliseconds(100)); |
| 110 | auto now = steady_timer::clock_type::now(); |
| 111 | t.async_wait( |
| 112 | cancel_at(cancellation_timer1, now + chronons::seconds(5), |
| 113 | bindns::bind(&increment_on_cancel, |
| 114 | &count, bindns::placeholders::_1))); |
| 115 | |
| 116 | ioc.run(); |
| 117 | |
| 118 | BOOST_ASIO_CHECK(count == 0); |
| 119 | |
| 120 | t.expires_after(chronons::seconds(5)); |
| 121 | now = steady_timer::clock_type::now(); |
| 122 | t.async_wait( |
| 123 | cancel_at(cancellation_timer1, now + chronons::milliseconds(100), |
| 124 | bindns::bind(&increment_on_cancel, |
| 125 | &count, bindns::placeholders::_1))); |
| 126 | |
| 127 | ioc.restart(); |
| 128 | ioc.run(); |
| 129 | |
| 130 | BOOST_ASIO_CHECK(count == 1); |
| 131 | |
| 132 | t.expires_after(chronons::milliseconds(100)); |
| 133 | now = steady_timer::clock_type::now(); |
| 134 | t.async_wait( |
| 135 | cancel_at(cancellation_timer1, now + chronons::seconds(5), |
| 136 | cancel_at(cancellation_timer2, now + chronons::seconds(10), |
| 137 | bindns::bind(&increment_on_cancel, |
| 138 | &count, bindns::placeholders::_1)))); |
| 139 | |
| 140 | ioc.restart(); |
| 141 | ioc.run(); |
| 142 | |
| 143 | BOOST_ASIO_CHECK(count == 1); |
| 144 | |
| 145 | t.expires_after(chronons::seconds(5)); |
| 146 | now = steady_timer::clock_type::now(); |
| 147 | t.async_wait( |
| 148 | cancel_at(cancellation_timer1, now + chronons::milliseconds(100), |
| 149 | cancel_at(cancellation_timer2, now + chronons::seconds(10), |
| 150 | bindns::bind(&increment_on_cancel, |
| 151 | &count, bindns::placeholders::_1)))); |
| 152 | |
| 153 | ioc.restart(); |
| 154 | ioc.run(); |
| 155 | |
| 156 | BOOST_ASIO_CHECK(count == 2); |
| 157 | |
| 158 | t.expires_after(chronons::seconds(5)); |
| 159 | now = steady_timer::clock_type::now(); |
nothing calls this directly
no test coverage detected