diff options
author | abogutskiy <abogutskiy@yandex-team.ru> | 2022-02-10 16:50:06 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:50:06 +0300 |
commit | 0ba74a57f9d49cfef11e512659c5847b98867342 (patch) | |
tree | 5d5cb817648f650d76cf1076100726fd9b8448e8 /library/cpp/actors | |
parent | 78454ca6aab96463952682e635688185282ccdcd (diff) | |
download | ydb-0ba74a57f9d49cfef11e512659c5847b98867342.tar.gz |
Restoring authorship annotation for <abogutskiy@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'library/cpp/actors')
-rw-r--r-- | library/cpp/actors/dnscachelib/timekeeper.h | 44 |
1 files changed, 22 insertions, 22 deletions
diff --git a/library/cpp/actors/dnscachelib/timekeeper.h b/library/cpp/actors/dnscachelib/timekeeper.h index 4c4602f083..0528d8549c 100644 --- a/library/cpp/actors/dnscachelib/timekeeper.h +++ b/library/cpp/actors/dnscachelib/timekeeper.h @@ -1,8 +1,8 @@ #pragma once -#include <util/datetime/base.h> +#include <util/datetime/base.h> #include <util/generic/singleton.h> -#include <util/string/cast.h> +#include <util/string/cast.h> #include <util/system/thread.h> #include <util/system/event.h> #include <util/system/env.h> @@ -13,10 +13,10 @@ class TTimeKeeper { public: - static TInstant GetNow(void) { + static TInstant GetNow(void) { return TInstant::MicroSeconds(GetTime()); - } - + } + static time_t GetTime(void) { return Singleton<TTimeKeeper>()->CurrentTime.tv_sec; } @@ -27,41 +27,41 @@ public: TTimeKeeper() : Thread(&TTimeKeeper::Worker, this) - { + { ConstTime = !!GetEnv("TEST_TIME"); - if (ConstTime) { - try { + if (ConstTime) { + try { CurrentTime.tv_sec = FromString<ui32>(GetEnv("TEST_TIME")); - } catch (TFromStringException exc) { - ConstTime = false; - } - } - if (!ConstTime) { + } catch (TFromStringException exc) { + ConstTime = false; + } + } + if (!ConstTime) { gettimeofday(&CurrentTime, nullptr); - Thread.Start(); - } + Thread.Start(); + } } ~TTimeKeeper() { - if (!ConstTime) { - Exit.Signal(); - Thread.Join(); - } + if (!ConstTime) { + Exit.Signal(); + Thread.Join(); + } } private: static const ui32 UpdateInterval = 100000; struct timeval CurrentTime; - bool ConstTime; + bool ConstTime; TSystemEvent Exit; TThread Thread; static void* Worker(void* arg) { TTimeKeeper* owner = static_cast<TTimeKeeper*>(arg); - + do { /* Race condition may occur here but locking looks too expensive */ - + gettimeofday(&owner->CurrentTime, nullptr); } while (!owner->Exit.WaitT(TDuration::MicroSeconds(UpdateInterval))); |