diff options
author | Marcos José Grillo Ramírez <marcos.grillo@10gen.com> | 2019-10-30 16:03:52 +0000 |
---|---|---|
committer | evergreen <evergreen@mongodb.com> | 2019-10-30 16:03:52 +0000 |
commit | 46ab40ac2c604c2fb09488856cadbb751df2572f (patch) | |
tree | b4c293b2ec28362b4c22e6449ac19946195ca68a /src/mongo/db/sessions_collection_mock.cpp | |
parent | 1c4b9635631a8408b626fa9259d1c83860c0c054 (diff) | |
download | mongo-46ab40ac2c604c2fb09488856cadbb751df2572f.tar.gz |
SERVER-42508 Convert SessionsCollection to throw instead of return status
Change the remaining public functions: refreshSessions, removeRecords and findRemovedSessions
Diffstat (limited to 'src/mongo/db/sessions_collection_mock.cpp')
-rw-r--r-- | src/mongo/db/sessions_collection_mock.cpp | 25 |
1 files changed, 11 insertions, 14 deletions
diff --git a/src/mongo/db/sessions_collection_mock.cpp b/src/mongo/db/sessions_collection_mock.cpp index 00992744589..1919e7d5bf0 100644 --- a/src/mongo/db/sessions_collection_mock.cpp +++ b/src/mongo/db/sessions_collection_mock.cpp @@ -35,8 +35,8 @@ namespace mongo { MockSessionsCollectionImpl::MockSessionsCollectionImpl() - : _refresh([=](const LogicalSessionRecordSet& sessions) { return _refreshSessions(sessions); }), - _remove([=](const LogicalSessionIdSet& sessions) { return _removeRecords(sessions); }) {} + : _refresh([=](const LogicalSessionRecordSet& sessions) { _refreshSessions(sessions); }), + _remove([=](const LogicalSessionIdSet& sessions) { _removeRecords(sessions); }) {} void MockSessionsCollectionImpl::setRefreshHook(RefreshHook hook) { _refresh = std::move(hook); @@ -47,16 +47,16 @@ void MockSessionsCollectionImpl::setRemoveHook(RemoveHook hook) { } void MockSessionsCollectionImpl::clearHooks() { - _refresh = [=](const LogicalSessionRecordSet& sessions) { return _refreshSessions(sessions); }; - _remove = [=](const LogicalSessionIdSet& sessions) { return _removeRecords(sessions); }; + _refresh = [=](const LogicalSessionRecordSet& sessions) { _refreshSessions(sessions); }; + _remove = [=](const LogicalSessionIdSet& sessions) { _removeRecords(sessions); }; } -Status MockSessionsCollectionImpl::refreshSessions(const LogicalSessionRecordSet& sessions) { - return _refresh(sessions); +void MockSessionsCollectionImpl::refreshSessions(const LogicalSessionRecordSet& sessions) { + _refresh(sessions); } -Status MockSessionsCollectionImpl::removeRecords(const LogicalSessionIdSet& sessions) { - return _remove(std::move(sessions)); +void MockSessionsCollectionImpl::removeRecords(const LogicalSessionIdSet& sessions) { + _remove(std::move(sessions)); } void MockSessionsCollectionImpl::add(LogicalSessionRecord record) { @@ -83,25 +83,22 @@ const MockSessionsCollectionImpl::SessionMap& MockSessionsCollectionImpl::sessio return _sessions; } -Status MockSessionsCollectionImpl::_refreshSessions(const LogicalSessionRecordSet& sessions) { +void MockSessionsCollectionImpl::_refreshSessions(const LogicalSessionRecordSet& sessions) { for (auto& record : sessions) { if (!has(record.getId())) { _sessions.insert({record.getId(), record}); } } - return Status::OK(); } -Status MockSessionsCollectionImpl::_removeRecords(const LogicalSessionIdSet& sessions) { +void MockSessionsCollectionImpl::_removeRecords(const LogicalSessionIdSet& sessions) { stdx::unique_lock<Latch> lk(_mutex); for (auto& lsid : sessions) { _sessions.erase(lsid); } - - return Status::OK(); } -StatusWith<LogicalSessionIdSet> MockSessionsCollectionImpl::findRemovedSessions( +LogicalSessionIdSet MockSessionsCollectionImpl::findRemovedSessions( OperationContext* opCtx, const LogicalSessionIdSet& sessions) { LogicalSessionIdSet lsids; stdx::unique_lock<Latch> lk(_mutex); |