diff options
Diffstat (limited to 'src/mongo/db/service_context.cpp')
-rw-r--r-- | src/mongo/db/service_context.cpp | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/src/mongo/db/service_context.cpp b/src/mongo/db/service_context.cpp index 350e9eae02e..148c2ebbc83 100644 --- a/src/mongo/db/service_context.cpp +++ b/src/mongo/db/service_context.cpp @@ -52,6 +52,7 @@ #include "mongo/util/str.h" #include "mongo/util/system_clock_source.h" #include "mongo/util/system_tick_source.h" +#include <iostream> namespace mongo { namespace { @@ -96,7 +97,7 @@ ServiceContext::ServiceContext() _preciseClockSource(std::make_unique<SystemClockSource>()) {} ServiceContext::~ServiceContext() { - stdx::lock_guard<stdx::mutex> lk(_mutex); + stdx::lock_guard<Latch> lk(_mutex); for (const auto& client : _clients) { severe() << "Client " << client->desc() << " still exists while destroying ServiceContext@" << static_cast<void*>(this); @@ -161,7 +162,7 @@ ServiceContext::UniqueClient ServiceContext::makeClient(std::string desc, std::unique_ptr<Client> client(new Client(std::move(desc), this, std::move(session))); onCreate(client.get(), _clientObservers); { - stdx::lock_guard<stdx::mutex> lk(_mutex); + stdx::lock_guard<Latch> lk(_mutex); invariant(_clients.insert(client.get()).second); } return UniqueClient(client.release()); @@ -225,7 +226,7 @@ void ServiceContext::setServiceExecutor(std::unique_ptr<transport::ServiceExecut void ServiceContext::ClientDeleter::operator()(Client* client) const { ServiceContext* const service = client->getServiceContext(); { - stdx::lock_guard<stdx::mutex> lk(service->_mutex); + stdx::lock_guard<Latch> lk(service->_mutex); invariant(service->_clients.erase(client)); } onDestroy(client, service->_clientObservers); @@ -291,7 +292,7 @@ Client* ServiceContext::LockedClientsCursor::next() { } void ServiceContext::setKillAllOperations() { - stdx::lock_guard<stdx::mutex> clientLock(_mutex); + stdx::lock_guard<Latch> clientLock(_mutex); // Ensure that all newly created operation contexts will immediately be in the interrupted state _globalKill.store(true); @@ -332,17 +333,17 @@ void ServiceContext::unsetKillAllOperations() { } void ServiceContext::registerKillOpListener(KillOpListenerInterface* listener) { - stdx::lock_guard<stdx::mutex> clientLock(_mutex); + stdx::lock_guard<Latch> clientLock(_mutex); _killOpListeners.push_back(listener); } void ServiceContext::waitForStartupComplete() { - stdx::unique_lock<stdx::mutex> lk(_mutex); + stdx::unique_lock<Latch> lk(_mutex); _startupCompleteCondVar.wait(lk, [this] { return _startupComplete; }); } void ServiceContext::notifyStartupComplete() { - stdx::unique_lock<stdx::mutex> lk(_mutex); + stdx::unique_lock<Latch> lk(_mutex); _startupComplete = true; lk.unlock(); _startupCompleteCondVar.notify_all(); |