summaryrefslogtreecommitdiff
path: root/src/mongo/db/client.h
diff options
context:
space:
mode:
authorMark Benvenuto <mark.benvenuto@mongodb.com>2015-06-20 00:22:50 -0400
committerMark Benvenuto <mark.benvenuto@mongodb.com>2015-06-20 10:56:02 -0400
commit9c2ed42daa8fbbef4a919c21ec564e2db55e8d60 (patch)
tree3814f79c10d7b490948d8cb7b112ac1dd41ceff1 /src/mongo/db/client.h
parent01965cf52bce6976637ecb8f4a622aeb05ab256a (diff)
downloadmongo-9c2ed42daa8fbbef4a919c21ec564e2db55e8d60.tar.gz
SERVER-18579: Clang-Format - reformat code, no comment reflow
Diffstat (limited to 'src/mongo/db/client.h')
-rw-r--r--src/mongo/db/client.h221
1 files changed, 117 insertions, 104 deletions
diff --git a/src/mongo/db/client.h b/src/mongo/db/client.h
index 4f27c639b0a..bff49a38ef3 100644
--- a/src/mongo/db/client.h
+++ b/src/mongo/db/client.h
@@ -47,109 +47,122 @@
namespace mongo {
- class Collection;
- class AbstractMessagingPort;
-
- typedef long long ConnectionId;
-
- /** the database's concept of an outside "client" */
- class Client : public ClientBasic {
- public:
- /** each thread which does db operations has a Client object in TLS.
- * call this when your thread starts.
- */
- static void initThread(const char *desc, AbstractMessagingPort *mp = 0);
- static void initThread(const char* desc,
- ServiceContext* serviceContext,
- AbstractMessagingPort* mp);
-
- /**
- * Inits a thread if that thread has not already been init'd, setting the thread name to
- * "desc".
- */
- static void initThreadIfNotAlready(const char* desc);
-
- /**
- * Inits a thread if that thread has not already been init'd, using the existing thread name
- */
- static void initThreadIfNotAlready();
-
- std::string clientAddress(bool includePort = false) const;
- const std::string& desc() const { return _desc; }
-
- void reportState(BSONObjBuilder& builder);
-
- // Ensures stability of the client's OperationContext. When the client is locked,
- // the OperationContext will not disappear.
- void lock() { _lock.lock(); }
- void unlock() { _lock.unlock(); }
-
- /**
- * Makes a new operation context representing an operation on this client. At most
- * one operation context may be in scope on a client at a time.
- */
- ServiceContext::UniqueOperationContext makeOperationContext();
-
- /**
- * 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();
-
- /**
- * 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; }
- void setInDirectClient(bool newVal) { _inDirectClient = newVal; }
-
- ConnectionId getConnectionId() const { return _connectionId; }
- bool isFromUserConnection() const { return _connectionId > 0; }
-
- private:
- friend class ServiceContext;
- Client(std::string desc,
- ServiceContext* serviceContext,
- AbstractMessagingPort *p = 0);
-
-
- // Description for the client (e.g. conn8)
- const std::string _desc;
-
- // OS id of the thread, which owns this client
- const stdx::thread::id _threadId;
-
- // > 0 for things "conn", 0 otherwise
- const ConnectionId _connectionId;
-
- // Protects the contents of the Client (such as changing the OperationContext, etc)
- mutable SpinLock _lock;
-
- // Whether this client is running as DBDirectClient
- bool _inDirectClient = false;
-
- // If != NULL, then contains the currently active OperationContext
- OperationContext* _txn = nullptr;
- };
-
- /** get the Client object for this thread. */
- Client& cc();
-
- bool haveClient();
+class Collection;
+class AbstractMessagingPort;
+
+typedef long long ConnectionId;
+
+/** the database's concept of an outside "client" */
+class Client : public ClientBasic {
+public:
+ /** each thread which does db operations has a Client object in TLS.
+ * call this when your thread starts.
+ */
+ static void initThread(const char* desc, AbstractMessagingPort* mp = 0);
+ static void initThread(const char* desc,
+ ServiceContext* serviceContext,
+ AbstractMessagingPort* mp);
+
+ /**
+ * Inits a thread if that thread has not already been init'd, setting the thread name to
+ * "desc".
+ */
+ static void initThreadIfNotAlready(const char* desc);
+
+ /**
+ * Inits a thread if that thread has not already been init'd, using the existing thread name
+ */
+ static void initThreadIfNotAlready();
+
+ std::string clientAddress(bool includePort = false) const;
+ const std::string& desc() const {
+ return _desc;
+ }
+
+ void reportState(BSONObjBuilder& builder);
+
+ // Ensures stability of the client's OperationContext. When the client is locked,
+ // the OperationContext will not disappear.
+ void lock() {
+ _lock.lock();
+ }
+ void unlock() {
+ _lock.unlock();
+ }
+
+ /**
+ * Makes a new operation context representing an operation on this client. At most
+ * one operation context may be in scope on a client at a time.
+ */
+ ServiceContext::UniqueOperationContext makeOperationContext();
+
+ /**
+ * 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();
+
+ /**
+ * 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;
+ }
+ void setInDirectClient(bool newVal) {
+ _inDirectClient = newVal;
+ }
+
+ ConnectionId getConnectionId() const {
+ return _connectionId;
+ }
+ bool isFromUserConnection() const {
+ return _connectionId > 0;
+ }
+
+private:
+ friend class ServiceContext;
+ Client(std::string desc, ServiceContext* serviceContext, AbstractMessagingPort* p = 0);
+
+
+ // Description for the client (e.g. conn8)
+ const std::string _desc;
+
+ // OS id of the thread, which owns this client
+ const stdx::thread::id _threadId;
+
+ // > 0 for things "conn", 0 otherwise
+ const ConnectionId _connectionId;
+
+ // Protects the contents of the Client (such as changing the OperationContext, etc)
+ mutable SpinLock _lock;
+
+ // Whether this client is running as DBDirectClient
+ bool _inDirectClient = false;
+
+ // If != NULL, then contains the currently active OperationContext
+ OperationContext* _txn = nullptr;
+};
+
+/** get the Client object for this thread. */
+Client& cc();
+bool haveClient();
};