summaryrefslogtreecommitdiff
path: root/src/mongo/db/client.cpp
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.cpp
parent01965cf52bce6976637ecb8f4a622aeb05ab256a (diff)
downloadmongo-9c2ed42daa8fbbef4a919c21ec564e2db55e8d60.tar.gz
SERVER-18579: Clang-Format - reformat code, no comment reflow
Diffstat (limited to 'src/mongo/db/client.cpp')
-rw-r--r--src/mongo/db/client.cpp162
1 files changed, 80 insertions, 82 deletions
diff --git a/src/mongo/db/client.cpp b/src/mongo/db/client.cpp
index 8ab9a7995f3..5da6d24c835 100644
--- a/src/mongo/db/client.cpp
+++ b/src/mongo/db/client.cpp
@@ -49,106 +49,104 @@
namespace mongo {
- using logger::LogComponent;
+using logger::LogComponent;
- TSP_DECLARE(ServiceContext::UniqueClient, currentClient)
- TSP_DEFINE(ServiceContext::UniqueClient, currentClient)
+TSP_DECLARE(ServiceContext::UniqueClient, currentClient)
+TSP_DEFINE(ServiceContext::UniqueClient, currentClient)
- void Client::initThreadIfNotAlready(const char* desc) {
- if (currentClient.getMake()->get())
- return;
- initThread(desc);
- }
+void Client::initThreadIfNotAlready(const char* desc) {
+ if (currentClient.getMake()->get())
+ return;
+ initThread(desc);
+}
- void Client::initThreadIfNotAlready() {
- initThreadIfNotAlready(getThreadName().c_str());
- }
+void Client::initThreadIfNotAlready() {
+ initThreadIfNotAlready(getThreadName().c_str());
+}
- void Client::initThread(const char *desc, AbstractMessagingPort *mp) {
- initThread(desc, getGlobalServiceContext(), mp);
- }
+void Client::initThread(const char* desc, AbstractMessagingPort* mp) {
+ initThread(desc, getGlobalServiceContext(), mp);
+}
- /**
- * This must be called whenever a new thread is started, so that active threads can be tracked
- * so each thread has a Client object in TLS.
- */
- void Client::initThread(const char *desc, ServiceContext* service, AbstractMessagingPort *mp) {
- invariant(currentClient.getMake()->get() == nullptr);
-
- std::string fullDesc;
- if (mp != NULL) {
- fullDesc = str::stream() << desc << mp->connectionId();
- }
- else {
- fullDesc = desc;
- }
-
- setThreadName(fullDesc.c_str());
-
- // Create the client obj, attach to thread
- *currentClient.get() = service->makeClient(fullDesc, mp);
+/**
+ * This must be called whenever a new thread is started, so that active threads can be tracked
+ * so each thread has a Client object in TLS.
+ */
+void Client::initThread(const char* desc, ServiceContext* service, AbstractMessagingPort* mp) {
+ invariant(currentClient.getMake()->get() == nullptr);
+
+ std::string fullDesc;
+ if (mp != NULL) {
+ fullDesc = str::stream() << desc << mp->connectionId();
+ } else {
+ fullDesc = desc;
}
- Client::Client(std::string desc,
- ServiceContext* serviceContext,
- AbstractMessagingPort *p)
- : ClientBasic(serviceContext, p),
- _desc(std::move(desc)),
- _threadId(stdx::this_thread::get_id()),
- _connectionId(p ? p->connectionId() : 0) {
- }
+ setThreadName(fullDesc.c_str());
- void Client::reportState(BSONObjBuilder& builder) {
- builder.append("desc", desc());
+ // Create the client obj, attach to thread
+ *currentClient.get() = service->makeClient(fullDesc, mp);
+}
- std::stringstream ss;
- ss << _threadId;
- builder.append("threadId", ss.str());
+Client::Client(std::string desc, ServiceContext* serviceContext, AbstractMessagingPort* p)
+ : ClientBasic(serviceContext, p),
+ _desc(std::move(desc)),
+ _threadId(stdx::this_thread::get_id()),
+ _connectionId(p ? p->connectionId() : 0) {}
- if (_connectionId) {
- builder.appendNumber("connectionId", _connectionId);
- }
+void Client::reportState(BSONObjBuilder& builder) {
+ builder.append("desc", desc());
- if (hasRemote()) {
- builder.append("client", getRemote().toString());
- }
- }
+ std::stringstream ss;
+ ss << _threadId;
+ builder.append("threadId", ss.str());
- ServiceContext::UniqueOperationContext Client::makeOperationContext() {
- return getServiceContext()->makeOperationContext(this);
+ if (_connectionId) {
+ builder.appendNumber("connectionId", _connectionId);
}
- void Client::setOperationContext(OperationContext* txn) {
- // We can only set the OperationContext once before resetting it.
- invariant(txn != NULL && _txn == NULL);
- _txn = txn;
+ if (hasRemote()) {
+ builder.append("client", getRemote().toString());
}
-
- void Client::resetOperationContext() {
- invariant(_txn != NULL);
- _txn = NULL;
+}
+
+ServiceContext::UniqueOperationContext Client::makeOperationContext() {
+ return getServiceContext()->makeOperationContext(this);
+}
+
+void Client::setOperationContext(OperationContext* txn) {
+ // We can only set the OperationContext once before resetting it.
+ invariant(txn != NULL && _txn == NULL);
+ _txn = txn;
+}
+
+void Client::resetOperationContext() {
+ invariant(_txn != NULL);
+ _txn = NULL;
+}
+
+std::string Client::clientAddress(bool includePort) const {
+ if (!hasRemote()) {
+ return "";
}
-
- std::string Client::clientAddress(bool includePort) const {
- if (!hasRemote()) {
- return "";
- }
- if (includePort) {
- return getRemote().toString();
- }
- return getRemote().host();
+ if (includePort) {
+ return getRemote().toString();
}
+ return getRemote().host();
+}
- ClientBasic* ClientBasic::getCurrent() {
- return currentClient.getMake()->get();
- }
+ClientBasic* ClientBasic::getCurrent() {
+ return currentClient.getMake()->get();
+}
- Client& cc() {
- Client* c = currentClient.getMake()->get();
- verify(c);
- return *c;
- }
+Client& cc() {
+ Client* c = currentClient.getMake()->get();
+ verify(c);
+ return *c;
+}
- bool haveClient() { return currentClient.getMake()->get(); }
+bool haveClient() {
+ return currentClient.getMake()->get();
+}
-} // namespace mongo
+} // namespace mongo