T_CHECK_TIMEOUT(start, end, milliseconds(10));
}
-/*
- * Test scheduling a timeout from another timeout callback.
- */
-BOOST_AUTO_TEST_CASE(CallbackSchedulingTimeout) {
- TEventBase eventBase;
- StackWheelTimer t(&eventBase, milliseconds(10));
- const HHWheelTimer::Callback* nullCallback = nullptr;
-
- TestTimeout t1;
- // Delayed to simulate the steady_clock counter lagging
- TestTimeoutDelayed t2;
-
- t.scheduleTimeout(&t1, milliseconds(500));
- t1.fn = [&] { t.scheduleTimeout(&t2, milliseconds(1)); };
- // If t is in an inconsistent state, detachEventBase should fail.
- t2.fn = [&] { t.detachEventBase(); };
-
- BOOST_REQUIRE_EQUAL(t.count(), 1);
-
- eventBase.loop();
-
- BOOST_REQUIRE_EQUAL(t.count(), 0);
- BOOST_REQUIRE_EQUAL(t1.timestamps.size(), 1);
- BOOST_REQUIRE_EQUAL(t2.timestamps.size(), 1);
-}
-
/*
* Test cancelling a timeout when it is scheduled to be fired right away.
*/