diff options
author | samantharitter <samantha.ritter@10gen.com> | 2015-09-17 17:27:05 -0400 |
---|---|---|
committer | samantharitter <samantha.ritter@10gen.com> | 2015-09-18 11:01:42 -0400 |
commit | 6b3cbe1dcbe3fd9d9946b62c5faa9b47e5430d88 (patch) | |
tree | bc89482c8cb68dd778ae26cc4fa6839df97a6dd5 /src/mongo/executor/async_timer_mock.cpp | |
parent | c0db389c3f72280d9c82202e9ee6fc70e7a17027 (diff) | |
download | mongo-6b3cbe1dcbe3fd9d9946b62c5faa9b47e5430d88.tar.gz |
SERVER-20465 Cancel AsyncOp timeouts when operation completes
Diffstat (limited to 'src/mongo/executor/async_timer_mock.cpp')
-rw-r--r-- | src/mongo/executor/async_timer_mock.cpp | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/src/mongo/executor/async_timer_mock.cpp b/src/mongo/executor/async_timer_mock.cpp index 6b6a8814fe6..7460e840993 100644 --- a/src/mongo/executor/async_timer_mock.cpp +++ b/src/mongo/executor/async_timer_mock.cpp @@ -39,6 +39,10 @@ const Milliseconds kZeroMilliseconds = Milliseconds(0); AsyncTimerMockImpl::AsyncTimerMockImpl(Milliseconds expiration) : _timeLeft(expiration) {} +void AsyncTimerMockImpl::cancel() { + _callAllHandlers(asio::error::operation_aborted); +} + void AsyncTimerMockImpl::asyncWait(AsyncTimerInterface::Handler handler) { // If we have expired, run handler now instead of storing. if (_timeLeft == kZeroMilliseconds) { @@ -64,20 +68,24 @@ Milliseconds AsyncTimerMockImpl::timeLeft() { return _timeLeft; } -void AsyncTimerMockImpl::_callAllHandlers() { +void AsyncTimerMockImpl::_callAllHandlers(std::error_code ec) { for (auto elem = _handlers.begin(); elem != _handlers.end(); elem++) { const auto& handler = *elem; - handler(std::error_code()); + handler(ec); } _handlers.clear(); } void AsyncTimerMockImpl::_expire() { - _callAllHandlers(); + _callAllHandlers(std::error_code()); } AsyncTimerMock::AsyncTimerMock(std::shared_ptr<AsyncTimerMockImpl> timer) : _timer(timer) {} +void AsyncTimerMock::cancel() { + _timer->cancel(); +} + void AsyncTimerMock::asyncWait(AsyncTimerInterface::Handler handler) { _timer->asyncWait(handler); } |