MCPcopy Create free account
hub / github.com/boostorg/asio / partial_cancel_at_timer_test

Function partial_cancel_at_timer_test

test/cancel_at.cpp:516–541  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

514}
515
516void partial_cancel_at_timer_test()
517{
518 io_context ioc;
519 steady_timer cancellation_timer(ioc);
520 int count = 0;
521
522 steady_timer t(ioc, chronons::milliseconds(100));
523 auto now = steady_timer::clock_type::now();
524 t.async_wait(cancel_at(cancellation_timer, now + chronons::seconds(5)))(
525 incrementer_token_v2(&count));
526
527 ioc.run();
528
529 BOOST_ASIO_CHECK(count == 0);
530
531 t.expires_after(chronons::seconds(5));
532 now = steady_timer::clock_type::now();
533 t.async_wait(
534 cancel_at(cancellation_timer, now + chronons::milliseconds(100)))(
535 incrementer_token_v2(&count));
536
537 ioc.restart();
538 ioc.run();
539
540 BOOST_ASIO_CHECK(count == 1);
541}
542
543BOOST_ASIO_TEST_SUITE
544(

Callers

nothing calls this directly

Calls 6

restartMethod · 0.80
nowFunction · 0.70
async_waitMethod · 0.45
runMethod · 0.45
expires_afterMethod · 0.45

Tested by

no test coverage detected