summaryrefslogtreecommitdiff
path: root/src/mongo/util/clock_source.h
diff options
context:
space:
mode:
authorBen Caimano <ben.caimano@mongodb.com>2019-10-09 21:40:44 +0000
committerevergreen <evergreen@mongodb.com>2019-10-09 21:40:44 +0000
commit97ffc69bea04758e1c7f94e1075ef2bcce652999 (patch)
treed7706b8bb2fad8458febc2c5fac9f570ccbab966 /src/mongo/util/clock_source.h
parent906ac3ca78d352df2d0dd45350195251efe0dea1 (diff)
downloadmongo-97ffc69bea04758e1c7f94e1075ef2bcce652999.tar.gz
SERVER-43800 ClockSource::waitForConditionUntil shouldn't use unique_lock out of line
Diffstat (limited to 'src/mongo/util/clock_source.h')
-rw-r--r--src/mongo/util/clock_source.h6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/mongo/util/clock_source.h b/src/mongo/util/clock_source.h
index c27d22b1dd3..f202f67f439 100644
--- a/src/mongo/util/clock_source.h
+++ b/src/mongo/util/clock_source.h
@@ -55,6 +55,8 @@ class ClockSource {
std::is_function<std::remove_pointer_t<PredicateT>>::value> {
};
+ static constexpr auto kMaxTimeoutForArtificialClocks = Seconds(1);
+
public:
virtual ~ClockSource() = default;
@@ -90,6 +92,10 @@ public:
/**
* Like cv.wait_until(m, deadline), but uses this ClockSource instead of
* stdx::chrono::system_clock to measure the passage of time.
+ *
+ * Note that this can suffer spurious wakeups like cw.wait_until() and, when used with a mocked
+ * clock source, may sleep in system time for kMaxTimeoutForArtificialClocks due to unfortunate
+ * implementation details.
*/
stdx::cv_status waitForConditionUntil(stdx::condition_variable& cv,
BasicLockableAdapter m,