summaryrefslogtreecommitdiff
path: root/src/mongo/db/client.cpp
diff options
context:
space:
mode:
authorGregory Wlodarek <gregory.wlodarek@mongodb.com>2018-11-01 18:51:15 -0400
committerGregory Wlodarek <gregory.wlodarek@mongodb.com>2018-11-08 18:35:00 -0500
commitaff889b39301472bd2143967938a3dba468dfc63 (patch)
tree2ee4fcec926d96a674690e390d5b916b4b9c7a3b /src/mongo/db/client.cpp
parent4fb38d9c10123321dada6fe1be477f9cb99732a7 (diff)
downloadmongo-aff889b39301472bd2143967938a3dba468dfc63.tar.gz
SERVER-36473 Make a dedicated RAII class to manage Client lifetime
Diffstat (limited to 'src/mongo/db/client.cpp')
-rw-r--r--src/mongo/db/client.cpp20
1 files changed, 15 insertions, 5 deletions
diff --git a/src/mongo/db/client.cpp b/src/mongo/db/client.cpp
index 1ac7d548bd2..da08647395b 100644
--- a/src/mongo/db/client.cpp
+++ b/src/mongo/db/client.cpp
@@ -88,11 +88,6 @@ void Client::initThread(StringData desc,
currentClient = service->makeClient(fullDesc, std::move(session));
}
-void Client::destroy() {
- invariant(haveClient());
- currentClient.reset(nullptr);
-}
-
namespace {
int64_t generateSeed(const std::string& desc) {
size_t seed = 0;
@@ -169,4 +164,19 @@ void Client::setCurrent(ServiceContext::UniqueClient client) {
currentClient = std::move(client);
}
+ThreadClient::ThreadClient(ServiceContext* serviceContext)
+ : ThreadClient(getThreadName(), serviceContext, nullptr) {}
+
+ThreadClient::ThreadClient(StringData desc,
+ ServiceContext* serviceContext,
+ transport::SessionHandle session) {
+ invariant(!currentClient);
+ Client::initThread(desc, serviceContext, std::move(session));
+}
+
+ThreadClient::~ThreadClient() {
+ invariant(currentClient);
+ currentClient.reset(nullptr);
+}
+
} // namespace mongo