summaryrefslogtreecommitdiff
path: root/src/mongo/db/operation_context.h
diff options
context:
space:
mode:
authorAndy Schwerin <schwerin@mongodb.com>2016-05-24 16:34:45 -0400
committerAndy Schwerin <schwerin@mongodb.com>2016-06-03 12:48:38 -0400
commit910e782aa5d8329c5e8b2531cf0116052e8a187e (patch)
tree8c7b17d5808ffaf4b8b9c4ff6a973e34d4b851eb /src/mongo/db/operation_context.h
parent0b5cbbadf49da830f20fba6e779b7278f211e394 (diff)
downloadmongo-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.h')
-rw-r--r--src/mongo/db/operation_context.h21
1 files changed, 17 insertions, 4 deletions
diff --git a/src/mongo/db/operation_context.h b/src/mongo/db/operation_context.h
index 07606c04715..0035bfa70d4 100644
--- a/src/mongo/db/operation_context.h
+++ b/src/mongo/db/operation_context.h
@@ -28,6 +28,8 @@
#pragma once
+#include <memory>
+
#include "mongo/base/disallow_copying.h"
#include "mongo/base/status.h"
#include "mongo/db/client.h"
@@ -109,9 +111,21 @@ public:
* Interface for locking. Caller DOES NOT own pointer.
*/
Locker* lockState() const {
- return _locker;
+ return _locker.get();
}
+ /**
+ * Sets the locker for use by this OperationContext. Call during OperationContext
+ * initialization, only.
+ */
+ void setLockState(std::unique_ptr<Locker> locker);
+
+ /**
+ * Releases the locker to the caller. Call during OperationContext cleanup or initialization,
+ * only.
+ */
+ std::unique_ptr<Locker> releaseLockState();
+
// --- operation level info? ---
/**
@@ -269,7 +283,7 @@ public:
Microseconds getRemainingMaxTimeMicros() const;
protected:
- OperationContext(Client* client, unsigned int opId, Locker* locker);
+ OperationContext(Client* client, unsigned int opId);
private:
/**
@@ -288,8 +302,7 @@ private:
Client* const _client;
const unsigned int _opId;
- // Not owned.
- Locker* const _locker;
+ std::unique_ptr<Locker> _locker;
std::unique_ptr<RecoveryUnit> _recoveryUnit;
RecoveryUnitState _ruState = kNotInUnitOfWork;