diff options
author | Anton Samokhvalov <pg83@yandex.ru> | 2022-02-10 16:45:17 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:45:17 +0300 |
commit | d3a398281c6fd1d3672036cb2d63f842d2cb28c5 (patch) | |
tree | dd4bd3ca0f36b817e96812825ffaf10d645803f2 /util/system/condvar.h | |
parent | 72cb13b4aff9bc9cf22e49251bc8fd143f82538f (diff) | |
download | ydb-d3a398281c6fd1d3672036cb2d63f842d2cb28c5.tar.gz |
Restoring authorship annotation for Anton Samokhvalov <pg83@yandex.ru>. Commit 2 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 82d6ca3d20..569162717c 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_; +}; |