| 13 | BOOST_AUTO_TEST_SUITE(base_io_engine) |
| 14 | |
| 15 | BOOST_AUTO_TEST_CASE(timeout_run) |
| 16 | { |
| 17 | boost::asio::io_context io; |
| 18 | boost::asio::io_context::strand strand (io); |
| 19 | int called = 0; |
| 20 | |
| 21 | IoEngine::SpawnCoroutine(strand, [&](boost::asio::yield_context yc) { |
| 22 | boost::asio::deadline_timer timer (io); |
| 23 | |
| 24 | Timeout timeout (strand, boost::posix_time::millisec(300), [&called] { ++called; }); |
| 25 | BOOST_CHECK_EQUAL(called, 0); |
| 26 | |
| 27 | timer.expires_from_now(boost::posix_time::millisec(200)); |
| 28 | timer.async_wait(yc); |
| 29 | BOOST_CHECK_EQUAL(called, 0); |
| 30 | |
| 31 | timer.expires_from_now(boost::posix_time::millisec(200)); |
| 32 | timer.async_wait(yc); |
| 33 | }); |
| 34 | |
| 35 | std::thread eventLoop ([&io] { io.run(); }); |
| 36 | io.run(); |
| 37 | eventLoop.join(); |
| 38 | |
| 39 | BOOST_CHECK_EQUAL(called, 1); |
| 40 | } |
| 41 | |
| 42 | BOOST_AUTO_TEST_CASE(timeout_cancelled) |
| 43 | { |