summaryrefslogtreecommitdiff
path: root/src/mongo/db/client.h
diff options
context:
space:
mode:
authorAndy Schwerin <schwerin@mongodb.com>2015-06-01 17:26:06 -0400
committerAndy Schwerin <schwerin@mongodb.com>2015-06-02 12:02:30 -0400
commit5f225a7464862686a8422bb02d1f638d5568d529 (patch)
treee09dbc2ba28fc12ad6fb5f3c438f2d91550cc01b /src/mongo/db/client.h
parentc561f5178239654cfbf14d398ab0fea1f08f5002 (diff)
downloadmongo-5f225a7464862686a8422bb02d1f638d5568d529.tar.gz
Reapply "SERVER-18277 Clarify locking of Client when accessing its stored OperationContext."
This reverts commit 993fc5e4ed9264965f16a948d3732d3fc55d1255.
Diffstat (limited to 'src/mongo/db/client.h')
-rw-r--r--src/mongo/db/client.h24
1 files changed, 21 insertions, 3 deletions
diff --git a/src/mongo/db/client.h b/src/mongo/db/client.h
index 63750b69523..597ed07dd70 100644
--- a/src/mongo/db/client.h
+++ b/src/mongo/db/client.h
@@ -86,11 +86,29 @@ namespace mongo {
void lock() { _lock.lock(); }
void unlock() { _lock.unlock(); }
- // Changes the currently active operation context on this client. There can only be one
- // active OperationContext at a time.
+ /**
+ * Sets the active operation context on this client to "txn", which must be non-NULL.
+ *
+ * It is an error to call this method if there is already an operation context on Client.
+ * It is an error to call this on an unlocked client.
+ */
void setOperationContext(OperationContext* txn);
+
+ /**
+ * Clears the active operation context on this client.
+ *
+ * There must already be such a context set on this client.
+ * It is an error to call this on an unlocked client.
+ */
void resetOperationContext();
- const OperationContext* getOperationContext() const { return _txn; }
+
+ /**
+ * Gets the operation context active on this client, or nullptr if there is no such context.
+ *
+ * It is an error to call this method on an unlocked client, or to use the value returned
+ * by this method while the client is not locked.
+ */
+ OperationContext* getOperationContext() { return _txn; }
// TODO(spencer): SERVER-10228 SERVER-14779 Remove this/move it fully into OperationContext.
bool isInDirectClient() const { return _inDirectClient; }