diff options
author | Anton Samokhvalov <pg83@yandex.ru> | 2022-02-10 16:45:15 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:45:15 +0300 |
commit | 72cb13b4aff9bc9cf22e49251bc8fd143f82538f (patch) | |
tree | da2c34829458c7d4e74bdfbdf85dff449e9e7fb8 /util/system/condvar.h | |
parent | 778e51ba091dc39e7b7fcab2b9cf4dbedfb6f2b5 (diff) | |
download | ydb-72cb13b4aff9bc9cf22e49251bc8fd143f82538f.tar.gz |
Restoring authorship annotation for Anton Samokhvalov <pg83@yandex.ru>. Commit 1 of 2.
Diffstat (limited to 'util/system/condvar.h')
-rw-r--r-- | util/system/condvar.h | 56 |
1 files changed, 28 insertions, 28 deletions
diff --git a/util/system/condvar.h b/util/system/condvar.h index 569162717c..82d6ca3d20 100644 --- a/util/system/condvar.h +++ b/util/system/condvar.h @@ -1,26 +1,26 @@ #pragma once -#include "mutex.h" - +#include "mutex.h" + #include <util/generic/ptr.h> #include <util/generic/noncopyable.h> #include <util/datetime/base.h> #include <utility> -class TCondVar { -public: - TCondVar(); +class TCondVar { +public: + TCondVar(); ~TCondVar(); void BroadCast() noexcept; void Signal() noexcept; - /* - * returns false if failed by timeout - */ + /* + * returns false if failed by timeout + */ bool WaitD(TMutex& m, TInstant deadline) noexcept; - + template <typename P> inline bool WaitD(TMutex& m, TInstant deadline, P pred) noexcept { while (!pred()) { @@ -31,41 +31,41 @@ public: return true; } - /* - * returns false if failed by timeout - */ + /* + * returns false if failed by timeout + */ inline bool WaitT(TMutex& m, TDuration timeout) noexcept { return WaitD(m, timeout.ToDeadLine()); - } - + } + template <typename P> inline bool WaitT(TMutex& m, TDuration timeout, P pred) noexcept { return WaitD(m, timeout.ToDeadLine(), std::move(pred)); } - /* - * infinite wait - */ + /* + * infinite wait + */ inline void WaitI(TMutex& m) noexcept { - WaitD(m, TInstant::Max()); - } - + WaitD(m, TInstant::Max()); + } + template <typename P> inline void WaitI(TMutex& m, P pred) noexcept { WaitD(m, TInstant::Max(), std::move(pred)); } - //deprecated + //deprecated inline void Wait(TMutex& m) noexcept { - WaitI(m); - } - + WaitI(m); + } + template <typename P> inline void Wait(TMutex& m, P pred) noexcept { WaitI(m, std::move(pred)); } -private: - class TImpl; - THolder<TImpl> Impl_; -}; +private: + class TImpl; + THolder<TImpl> Impl_; +}; |