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