aboutsummaryrefslogtreecommitdiffstats
path: root/util/system/condvar.h
diff options
context:
space:
mode:
authoryazevnul <yazevnul@yandex-team.ru>2022-02-10 16:46:48 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:46:48 +0300
commit9abfb1a53b7f7b791444d1378e645d8fad9b06ed (patch)
tree49e222ea1c5804306084bb3ae065bb702625360f /util/system/condvar.h
parent8cbc307de0221f84c80c42dcbe07d40727537e2c (diff)
downloadydb-9abfb1a53b7f7b791444d1378e645d8fad9b06ed.tar.gz
Restoring authorship annotation for <yazevnul@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'util/system/condvar.h')
-rw-r--r--util/system/condvar.h60
1 files changed, 30 insertions, 30 deletions
diff --git a/util/system/condvar.h b/util/system/condvar.h
index 911ace52c6..569162717c 100644
--- a/util/system/condvar.h
+++ b/util/system/condvar.h
@@ -6,8 +6,8 @@
#include <util/generic/noncopyable.h>
#include <util/datetime/base.h>
-#include <utility>
-
+#include <utility>
+
class TCondVar {
public:
TCondVar();
@@ -19,30 +19,30 @@ public:
/*
* returns false if failed by timeout
*/
- bool WaitD(TMutex& m, TInstant deadline) noexcept;
+ bool WaitD(TMutex& m, TInstant deadline) noexcept;
+
+ template <typename P>
+ inline bool WaitD(TMutex& m, TInstant deadline, P pred) noexcept {
+ while (!pred()) {
+ if (!WaitD(m, deadline)) {
+ return pred();
+ }
+ }
+ return true;
+ }
- template <typename P>
- inline bool WaitD(TMutex& m, TInstant deadline, P pred) noexcept {
- while (!pred()) {
- if (!WaitD(m, deadline)) {
- return pred();
- }
- }
- return true;
- }
-
/*
* returns false if failed by timeout
*/
- inline bool WaitT(TMutex& m, TDuration timeout) noexcept {
- return WaitD(m, timeout.ToDeadLine());
+ 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));
}
- template <typename P>
- inline bool WaitT(TMutex& m, TDuration timeout, P pred) noexcept {
- return WaitD(m, timeout.ToDeadLine(), std::move(pred));
- }
-
/*
* infinite wait
*/
@@ -50,21 +50,21 @@ public:
WaitD(m, TInstant::Max());
}
- template <typename P>
- inline void WaitI(TMutex& m, P pred) noexcept {
- WaitD(m, TInstant::Max(), std::move(pred));
- }
-
+ template <typename P>
+ inline void WaitI(TMutex& m, P pred) noexcept {
+ WaitD(m, TInstant::Max(), std::move(pred));
+ }
+
//deprecated
inline void Wait(TMutex& m) noexcept {
WaitI(m);
}
- template <typename P>
- inline void Wait(TMutex& m, P pred) noexcept {
- WaitI(m, std::move(pred));
- }
-
+ template <typename P>
+ inline void Wait(TMutex& m, P pred) noexcept {
+ WaitI(m, std::move(pred));
+ }
+
private:
class TImpl;
THolder<TImpl> Impl_;