diff options
author | Andy Schwerin <schwerin@mongodb.com> | 2016-05-24 16:34:45 -0400 |
---|---|---|
committer | Andy Schwerin <schwerin@mongodb.com> | 2016-06-03 12:48:38 -0400 |
commit | 910e782aa5d8329c5e8b2531cf0116052e8a187e (patch) | |
tree | 8c7b17d5808ffaf4b8b9c4ff6a973e34d4b851eb /src/mongo/db/operation_context.cpp | |
parent | 0b5cbbadf49da830f20fba6e779b7278f211e394 (diff) | |
download | mongo-910e782aa5d8329c5e8b2531cf0116052e8a187e.tar.gz |
SERVER-23905 Unify lifetime management for LockState on OperationContexts into OperationContext.
This change also moves responsibility for registering OperationContexts to Clients into
ServiceContext::makeOperationContext.
Diffstat (limited to 'src/mongo/db/operation_context.cpp')
-rw-r--r-- | src/mongo/db/operation_context.cpp | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/src/mongo/db/operation_context.cpp b/src/mongo/db/operation_context.cpp index 93cb2604b2b..ae018c38d0e 100644 --- a/src/mongo/db/operation_context.cpp +++ b/src/mongo/db/operation_context.cpp @@ -35,6 +35,7 @@ #include "mongo/db/client.h" #include "mongo/db/service_context.h" #include "mongo/platform/random.h" +#include "mongo/stdx/mutex.h" #include "mongo/util/assert_util.h" #include "mongo/util/clock_source.h" #include "mongo/util/fail_point_service.h" @@ -72,10 +73,9 @@ MONGO_FP_DECLARE(checkForInterruptFail); } // namespace -OperationContext::OperationContext(Client* client, unsigned int opId, Locker* locker) +OperationContext::OperationContext(Client* client, unsigned int opId) : _client(client), _opId(opId), - _locker(locker), _elapsedTime(client ? client->getServiceContext()->getTickSource() : SystemTickSource::get()) {} @@ -216,4 +216,15 @@ OperationContext::RecoveryUnitState OperationContext::setRecoveryUnit(RecoveryUn return oldState; } +std::unique_ptr<Locker> OperationContext::releaseLockState() { + dassert(_locker); + return std::move(_locker); +} + +void OperationContext::setLockState(std::unique_ptr<Locker> locker) { + dassert(!_locker); + dassert(locker); + _locker = std::move(locker); +} + } // namespace mongo |