26 using namespace folly;
27 using std::chrono::milliseconds;
39 timestamps.emplace_back();
46 canceledTimestamps.emplace_back();
54 std::function<void()>
fn;
59 std::chrono::steady_clock::time_point
getCurTime()
override {
94 milliseconds(605 * 256),
95 milliseconds(256 * 256));
99 milliseconds(300 * 256),
100 milliseconds(256 * 256));
109 milliseconds interval(10);
110 milliseconds atMostEveryN(3);
115 std::vector<TestTimeout> timeouts(numTimeouts);
122 if (index >= numTimeouts) {
134 timeouts[index].timeoutExpired();
149 if (std::chrono::duration_cast<std::chrono::milliseconds>(
152 LOG(
WARNING) <<
"scheduling all timeouts takes too long";
163 for (
uint32_t idx = 0; idx < numTimeouts; ++idx) {
164 ASSERT_EQ(timeouts[idx].timestamps.size(), 2);
166 TimePoint scheduledTime(timeouts[idx].timestamps[0]);
167 TimePoint firedTime(timeouts[idx].timestamps[1]);
172 milliseconds tolerance = milliseconds(5) + interval;
182 TimePoint prev(timeouts[idx - 1].timestamps[1]);
186 if (delta > milliseconds(1)) {
204 eventBase.runInLoop([]() {
206 std::this_thread::sleep_for(std::chrono::microseconds(10000));
223 eventBase.runInLoop([]() {
225 std::this_thread::sleep_for(std::chrono::microseconds(10000));
270 start, t1.
timestamps[0], milliseconds(605), milliseconds(256));
272 start, t2.
timestamps[0], milliseconds(300), milliseconds(256));
278 long timeoutcount = 10000;
280 long runtimeouts = 0;
281 for (
long i = 0;
i < timeoutcount;
i++) {
289 eventBase.runAfterDelay(
291 timeouts[
i].
fn =
nullptr;
294 LOG(
INFO) <<
"Ran " << runtimeouts <<
" timeouts, cancelled";
297 timeouts[
i].
fn = [&,
i, timeout]() {
298 LOG(
INFO) <<
"FAIL:timer " << i <<
" still fired in " << timeout;
303 timeouts[
i].
fn = [&,
i]() {
306 t.
scheduleTimeout(&timeouts[i], std::chrono::milliseconds(newtimeout));
309 LOG(
INFO) <<
"Ran " << runtimeouts <<
" timeouts of " << timeoutcount;
310 timeouts[
i].
fn = [&]() {
312 LOG(
INFO) <<
"Ran " << runtimeouts <<
" timeouts of " << timeoutcount;
318 LOG(
INFO) <<
"RUNNING TEST";
std::chrono::steady_clock::time_point getTime() const
UndelayedDestruction< HHWheelTimer > StackWheelTimer
#define ASSERT_EQ(val1, val2)
std::chrono::nanoseconds getTimeWaiting() const
std::deque< TimePoint > canceledTimestamps
#define EXPECT_EQ(val1, val2)
std::chrono::steady_clock::time_point now()
—— Concurrent Priority Queue Implementation ——
requires E e noexcept(noexcept(s.error(std::move(e))))
std::shared_ptr< folly::FunctionScheduler > scheduler
void scheduleTimeout(Callback *callback, std::chrono::milliseconds timeout)
std::deque< TimePoint > timestamps
TestTimeout(HHWheelTimer *t, milliseconds timeout)
void callbackCanceled() noexceptoverride
auto end(TestAdlIterable &instance)
void timeoutExpired() noexceptoverride
std::chrono::steady_clock::time_point getTimeStart() const
TEST_F(AsyncSSLSocketWriteTest, write_coalescing1)
std::size_t count() const
std::chrono::steady_clock::time_point getCurTime() override
std::function< void()> fn
#define T_CHECK_TIMEOUT(start, end, expectedMS,...)
std::chrono::steady_clock::time_point getTimeEnd() const