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

Function deadline_timer_thread_test

test/deadline_timer.cpp:362–386  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

360}
361
362void deadline_timer_thread_test()
363{
364 boost::asio::io_context ioc;
365 boost::asio::executor_work_guard<boost::asio::io_context::executor_type> work
366 = boost::asio::make_work_guard(ioc);
367 boost::asio::deadline_timer t1(ioc);
368 boost::asio::deadline_timer t2(ioc);
369 int count = 0;
370
371 boost::asio::detail::thread th(boost::bind(io_context_run, &ioc));
372
373 t2.expires_from_now(boost::posix_time::seconds(2));
374 t2.wait();
375
376 t1.expires_from_now(boost::posix_time::seconds(2));
377 t1.async_wait(boost::bind(increment, &count));
378
379 t2.expires_from_now(boost::posix_time::seconds(4));
380 t2.wait();
381
382 ioc.stop();
383 th.join();
384
385 BOOST_ASIO_CHECK(count == 1);
386}
387
388void deadline_timer_async_result_test()
389{

Callers

nothing calls this directly

Calls 6

expires_from_nowMethod · 0.80
bindFunction · 0.50
waitMethod · 0.45
async_waitMethod · 0.45
stopMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected