summaryrefslogtreecommitdiff
path: root/src/mongo/util/concurrency/notification.h
diff options
context:
space:
mode:
authorAndy Schwerin <Andy Schwerin schwerin@mongodb.com>2017-02-09 23:43:15 -0500
committerAndy Schwerin <Andy Schwerin schwerin@mongodb.com>2017-03-15 13:37:27 -0400
commit1515d4e4e2613e79b2c1761b7505cfaa9c31f0a9 (patch)
treecc067362d65a4082d62482f90dc65f94f3115bad /src/mongo/util/concurrency/notification.h
parent10c9d67de63a38249fca0234208660af8b45f12b (diff)
downloadmongo-1515d4e4e2613e79b2c1761b7505cfaa9c31f0a9.tar.gz
SERVER-25062 Fix return types of predicated waits and notification waitFor.
This patch makes the return types of predicated waits on condition variables and Notification::waitFor look more like the corresponding functions in C++ standard types.
Diffstat (limited to 'src/mongo/util/concurrency/notification.h')
-rw-r--r--src/mongo/util/concurrency/notification.h10
1 files changed, 4 insertions, 6 deletions
diff --git a/src/mongo/util/concurrency/notification.h b/src/mongo/util/concurrency/notification.h
index 091dca02a60..aa8df252110 100644
--- a/src/mongo/util/concurrency/notification.h
+++ b/src/mongo/util/concurrency/notification.h
@@ -100,12 +100,10 @@ public:
* If the notification is not set, blocks either until it becomes set or until the waitTimeout
* expires. If the wait is interrupted, throws an exception. Otherwise, returns immediately.
*/
- bool waitFor(OperationContext* opCtx, Microseconds waitTimeout) {
- const auto waitDeadline = Date_t::now() + waitTimeout;
-
+ bool waitFor(OperationContext* opCtx, Milliseconds waitTimeout) {
stdx::unique_lock<stdx::mutex> lock(_mutex);
- return _condVar.wait_until(
- lock, waitDeadline.toSystemTimePoint(), [&]() { return !!_value; });
+ return opCtx->waitForConditionOrInterruptFor(
+ _condVar, lock, waitTimeout, [&]() { return !!_value; });
}
private:
@@ -135,7 +133,7 @@ public:
_notification.set(true);
}
- bool waitFor(OperationContext* opCtx, Microseconds waitTimeout) {
+ bool waitFor(OperationContext* opCtx, Milliseconds waitTimeout) {
return _notification.waitFor(opCtx, waitTimeout);
}