forked from envoyproxy/envoy
-
Notifications
You must be signed in to change notification settings - Fork 44
/
Copy pathtest_time.cc
35 lines (24 loc) · 1005 Bytes
/
test_time.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include "test/test_common/test_time.h"
#include "common/common/utility.h"
#include "test/test_common/global.h"
namespace Envoy {
DangerousDeprecatedTestTime::DangerousDeprecatedTestTime() = default;
namespace Event {
TestTimeSystem& GlobalTimeSystem::timeSystem() {
// TODO(#4160): Switch default to SimulatedTimeSystem.
auto make_real_time_system = []() -> std::unique_ptr<TestTimeSystem> {
return std::make_unique<TestRealTimeSystem>();
};
return singleton_->timeSystem(make_real_time_system);
}
void TestRealTimeSystem::advanceTimeWaitImpl(const Duration& duration) {
only_one_thread_.checkOneThread();
std::this_thread::sleep_for(duration);
}
void TestRealTimeSystem::advanceTimeAsyncImpl(const Duration& duration) {
advanceTimeWait(duration);
}
SystemTime TestRealTimeSystem::systemTime() { return real_time_system_.systemTime(); }
MonotonicTime TestRealTimeSystem::monotonicTime() { return real_time_system_.monotonicTime(); }
} // namespace Event
} // namespace Envoy