diff options
| author | snaury <[email protected]> | 2023-05-16 13:43:28 +0300 |
|---|---|---|
| committer | snaury <[email protected]> | 2023-05-16 13:43:28 +0300 |
| commit | c9df7fc86be0b15adc1e812144c41ab5c057baef (patch) | |
| tree | 63c809b43d9e026188f6a66725ccac433ba0f734 /library/cpp/actors/testlib/test_runtime.cpp | |
| parent | a2e846788b0a6d372d15ab5de915616cc6bc00ce (diff) | |
Support monotonic boot time with suspend awareness
Diffstat (limited to 'library/cpp/actors/testlib/test_runtime.cpp')
| -rw-r--r-- | library/cpp/actors/testlib/test_runtime.cpp | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/library/cpp/actors/testlib/test_runtime.cpp b/library/cpp/actors/testlib/test_runtime.cpp index 6fedca1cd22..2ec0b27ddce 100644 --- a/library/cpp/actors/testlib/test_runtime.cpp +++ b/library/cpp/actors/testlib/test_runtime.cpp @@ -246,6 +246,20 @@ namespace NActors { TTestActorRuntimeBase& Runtime; }; + class TTestActorRuntimeBase::TBootTimeProvider : public IBootTimeProvider { + public: + TBootTimeProvider(TTestActorRuntimeBase& runtime) + : Runtime(runtime) + { } + + TBootTime Now() override { + return Runtime.GetCurrentBootTime(); + } + + private: + TTestActorRuntimeBase& Runtime; + }; + class TTestActorRuntimeBase::TSchedulerThreadStub : public ISchedulerThread { public: TSchedulerThreadStub(TTestActorRuntimeBase* runtime, TTestActorRuntimeBase::TNodeDataBase* node) @@ -496,6 +510,7 @@ namespace NActors { , RandomProvider(CreateDeterministicRandomProvider(DefaultRandomSeed)) , TimeProvider(new TTimeProvider(*this)) , MonotonicTimeProvider(new TMonotonicTimeProvider(*this)) + , BootTimeProvider(new TBootTimeProvider(*this)) , ShouldContinue() , CurrentTimestamp(0) , DispatchTimeout(DEFAULT_DISPATCH_TIMEOUT) @@ -829,6 +844,12 @@ namespace NActors { return TMonotonic::MicroSeconds(CurrentTimestamp); } + TBootTime TTestActorRuntimeBase::GetCurrentBootTime() const { + TGuard<TMutex> guard(Mutex); + Y_VERIFY(!UseRealThreads); + return TBootTime::MicroSeconds(CurrentTimestamp); + } + void TTestActorRuntimeBase::UpdateCurrentTime(TInstant newTime) { static int counter = 0; ++counter; @@ -860,6 +881,11 @@ namespace NActors { return MonotonicTimeProvider; } + TIntrusivePtr<IBootTimeProvider> TTestActorRuntimeBase::GetBootTimeProvider() { + Y_VERIFY(!UseRealThreads); + return BootTimeProvider; + } + ui32 TTestActorRuntimeBase::GetNodeId(ui32 index) const { Y_VERIFY(index < NodeCount); return FirstNodeId + index; |
