diff options
author | Andy Schwerin <Andy Schwerin schwerin@mongodb.com> | 2017-02-09 23:43:15 -0500 |
---|---|---|
committer | Andy Schwerin <Andy Schwerin schwerin@mongodb.com> | 2017-03-15 13:37:27 -0400 |
commit | 1515d4e4e2613e79b2c1761b7505cfaa9c31f0a9 (patch) | |
tree | cc067362d65a4082d62482f90dc65f94f3115bad /src/mongo/util/concurrency/notification.h | |
parent | 10c9d67de63a38249fca0234208660af8b45f12b (diff) | |
download | mongo-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.h | 10 |
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); } |