#include "time_provider.h" class TDefaultTimeProvider: public ITimeProvider { public: TInstant Now() override { return TInstant::Now(); } }; class TDeterministicTimeProvider: public ITimeProvider { public: TDeterministicTimeProvider(ui64 seed) { Value = TInstant::Seconds(seed); } TInstant Now() override { return Value; } private: TInstant Value; }; TIntrusivePtr CreateDefaultTimeProvider() { return TIntrusivePtr(new TDefaultTimeProvider()); } TIntrusivePtr CreateDeterministicTimeProvider(ui64 seed) { return TIntrusivePtr(new TDeterministicTimeProvider(seed)); } namespace { TIntrusivePtr GlobalTimeProvider; } void TInstantOperator::RegisterProvider(TIntrusivePtr provider) { GlobalTimeProvider = provider; } TInstant TInstantOperator::Now() { if (!GlobalTimeProvider) { return TInstant::Now(); } else { return GlobalTimeProvider->Now(); } }