From 0cba037a5bb5b4e75b964be02f37c630e1560b2a Mon Sep 17 00:00:00 2001 From: Henning Baldersheim Date: Mon, 14 Sep 2020 12:50:00 +0000 Subject: shared_timed_mutex -> shared_mutex --- .../proton/attribute/attributedisklayout.cpp | 10 ++++---- .../proton/attribute/attributedisklayout.h | 2 +- .../proton/persistenceengine/persistenceengine.cpp | 2 +- .../proton/persistenceengine/persistenceengine.h | 6 ++--- .../src/vespa/searchcore/proton/server/proton.cpp | 30 +++++++++++----------- .../src/vespa/searchcore/proton/server/proton.h | 2 +- 6 files changed, 26 insertions(+), 26 deletions(-) (limited to 'searchcore') diff --git a/searchcore/src/vespa/searchcore/proton/attribute/attributedisklayout.cpp b/searchcore/src/vespa/searchcore/proton/attribute/attributedisklayout.cpp index 5f057bbd7dc..246caa6cd35 100644 --- a/searchcore/src/vespa/searchcore/proton/attribute/attributedisklayout.cpp +++ b/searchcore/src/vespa/searchcore/proton/attribute/attributedisklayout.cpp @@ -23,7 +23,7 @@ std::vector AttributeDiskLayout::listAttributes() { std::vector attributes; - std::shared_lock guard(_mutex); + std::shared_lock guard(_mutex); for (const auto &dir : _dirs) { attributes.emplace_back(dir.first); } @@ -46,7 +46,7 @@ AttributeDiskLayout::scanDir() std::shared_ptr AttributeDiskLayout::getAttributeDir(const vespalib::string &name) { - std::shared_lock guard(_mutex); + std::shared_lock guard(_mutex); auto itr = _dirs.find(name); if (itr == _dirs.end()) { return std::shared_ptr(); @@ -58,7 +58,7 @@ AttributeDiskLayout::getAttributeDir(const vespalib::string &name) std::shared_ptr AttributeDiskLayout::createAttributeDir(const vespalib::string &name) { - std::lock_guard guard(_mutex); + std::lock_guard guard(_mutex); auto itr = _dirs.find(name); if (itr == _dirs.end()) { auto dir = std::make_shared(shared_from_this(), name); @@ -80,7 +80,7 @@ AttributeDiskLayout::removeAttributeDir(const vespalib::string &name, search::Se writer->invalidateOldSnapshots(serialNum); writer->removeInvalidSnapshots(); if (writer->removeDiskDir()) { - std::lock_guard guard(_mutex); + std::lock_guard guard(_mutex); auto itr = _dirs.find(name); assert(itr != _dirs.end()); assert(dir.get() == itr->second.get()); @@ -88,7 +88,7 @@ AttributeDiskLayout::removeAttributeDir(const vespalib::string &name, search::Se writer->detach(); } } else { - std::lock_guard guard(_mutex); + std::lock_guard guard(_mutex); auto itr = _dirs.find(name); if (itr != _dirs.end()) { assert(dir.get() != itr->second.get()); diff --git a/searchcore/src/vespa/searchcore/proton/attribute/attributedisklayout.h b/searchcore/src/vespa/searchcore/proton/attribute/attributedisklayout.h index 9e081f601bf..74cf0bb8cf8 100644 --- a/searchcore/src/vespa/searchcore/proton/attribute/attributedisklayout.h +++ b/searchcore/src/vespa/searchcore/proton/attribute/attributedisklayout.h @@ -19,7 +19,7 @@ class AttributeDiskLayout : public std::enable_shared_from_this> _dirs; void scanDir(); diff --git a/searchcore/src/vespa/searchcore/proton/persistenceengine/persistenceengine.cpp b/searchcore/src/vespa/searchcore/proton/persistenceengine/persistenceengine.cpp index 96ecccb0e6d..1ac313f2718 100644 --- a/searchcore/src/vespa/searchcore/proton/persistenceengine/persistenceengine.cpp +++ b/searchcore/src/vespa/searchcore/proton/persistenceengine/persistenceengine.cpp @@ -740,7 +740,7 @@ PersistenceEngine::populateInitialBucketDB(const WriteGuard & guard, BucketSpace trHandler.await(); } -std::unique_lock +std::unique_lock PersistenceEngine::getWLock() const { return WriteGuard(_rwMutex); diff --git a/searchcore/src/vespa/searchcore/proton/persistenceengine/persistenceengine.h b/searchcore/src/vespa/searchcore/proton/persistenceengine/persistenceengine.h index 27ebffd4ee3..9ee42823f9c 100644 --- a/searchcore/src/vespa/searchcore/proton/persistenceengine/persistenceengine.h +++ b/searchcore/src/vespa/searchcore/proton/persistenceengine/persistenceengine.h @@ -70,10 +70,10 @@ private: const IResourceWriteFilter &_writeFilter; std::unordered_map _clusterStates; mutable ExtraModifiedBuckets _extraModifiedBuckets; - mutable std::shared_timed_mutex _rwMutex; + mutable std::shared_mutex _rwMutex; - using ReadGuard = std::shared_lock; - using WriteGuard = std::unique_lock; + using ReadGuard = std::shared_lock; + using WriteGuard = std::unique_lock; IPersistenceHandler * getHandler(const ReadGuard & guard, document::BucketSpace bucketSpace, const DocTypeName &docType) const; HandlerSnapshot getHandlerSnapshot(const WriteGuard & guard) const; diff --git a/searchcore/src/vespa/searchcore/proton/server/proton.cpp b/searchcore/src/vespa/searchcore/proton/server/proton.cpp index c40f1263324..321662ea404 100644 --- a/searchcore/src/vespa/searchcore/proton/server/proton.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/proton.cpp @@ -492,7 +492,7 @@ Proton::closeDocumentDBs(vespalib::ThreadStackExecutorBase & executor) { size_t Proton::getNumDocs() const { size_t numDocs(0); - std::shared_lock guard(_mutex); + std::shared_lock guard(_mutex); for (const auto &kv : _documentDBMap) { numDocs += kv.second->getNumDocs(); } @@ -502,7 +502,7 @@ size_t Proton::getNumDocs() const size_t Proton::getNumActiveDocs() const { size_t numDocs(0); - std::shared_lock guard(_mutex); + std::shared_lock guard(_mutex); for (const auto &kv : _documentDBMap) { numDocs += kv.second->getNumActiveDocs(); } @@ -532,7 +532,7 @@ Proton::getDelayedConfigs() const { std::ostringstream res; bool first = true; - std::shared_lock guard(_mutex); + std::shared_lock guard(_mutex); for (const auto &kv : _documentDBMap) { if (kv.second->getDelayedConfig()) { if (!first) { @@ -549,7 +549,7 @@ StatusReport::List Proton::getStatusReports() const { StatusReport::List reports; - std::shared_lock guard(_mutex); + std::shared_lock guard(_mutex); reports.push_back(StatusReport::SP(_matchEngine->reportStatus())); for (const auto &kv : _documentDBMap) { reports.push_back(StatusReport::SP(kv.second->reportStatus())); @@ -566,7 +566,7 @@ Proton::addDocumentDB(const document::DocumentType &docType, { const ProtonConfig &config(bootstrapConfig->getProtonConfig()); - std::lock_guard guard(_mutex); + std::lock_guard guard(_mutex); DocTypeName docTypeName(docType.getName()); auto it = _documentDBMap.find(docTypeName); if (it != _documentDBMap.end()) { @@ -607,7 +607,7 @@ Proton::addDocumentDB(const document::DocumentType &docType, _documentDBMap[docTypeName] = ret; if (_persistenceEngine) { // Not allowed to get to service layer to call pause(). - std::unique_lock persistenceWGuard(_persistenceEngine->getWLock()); + std::unique_lock persistenceWGuard(_persistenceEngine->getWLock()); auto persistenceHandler = std::make_shared(ret); if (!_isInitializing) { _persistenceEngine->propagateSavedClusterState(bucketSpace, *persistenceHandler); @@ -632,7 +632,7 @@ Proton::removeDocumentDB(const DocTypeName &docTypeName) { DocumentDB::SP old; { - std::lock_guard guard(_mutex); + std::lock_guard guard(_mutex); auto it = _documentDBMap.find(docTypeName); if (it == _documentDBMap.end()) { return; @@ -645,7 +645,7 @@ Proton::removeDocumentDB(const DocTypeName &docTypeName) if (_persistenceEngine) { { // Not allowed to get to service layer to call pause(). - std::unique_lock persistenceWguard(_persistenceEngine->getWLock()); + std::unique_lock persistenceWguard(_persistenceEngine->getWLock()); IPersistenceHandler::SP oldHandler = _persistenceEngine->removeHandler(persistenceWguard, old->getBucketSpace(), docTypeName); if (_initComplete && oldHandler) { // TODO: Fix race with bucket db modifying ops. @@ -757,7 +757,7 @@ Proton::updateMetrics(const vespalib::MonitorGuard &) void Proton::waitForInitDone() { - std::shared_lock guard(_mutex); + std::shared_lock guard(_mutex); for (const auto &kv : _documentDBMap) { kv.second->waitForInitDone(); } @@ -766,7 +766,7 @@ Proton::waitForInitDone() void Proton::waitForOnlineState() { - std::shared_lock guard(_mutex); + std::shared_lock guard(_mutex); for (const auto &kv : _documentDBMap) { kv.second->waitForOnlineState(); } @@ -778,7 +778,7 @@ Proton::getComponentConfig(Consumer &consumer) _protonConfigurer.getComponentConfig().getComponentConfig(consumer); std::vector dbs; { - std::shared_lock guard(_mutex); + std::shared_lock guard(_mutex); for (const auto &kv : _documentDBMap) { dbs.push_back(kv.second); } @@ -847,12 +847,12 @@ struct StateExplorerProxy : vespalib::StateExplorer { struct DocumentDBMapExplorer : vespalib::StateExplorer { typedef std::map DocumentDBMap; const DocumentDBMap &documentDBMap; - std::shared_timed_mutex &mutex; - DocumentDBMapExplorer(const DocumentDBMap &documentDBMap_in, std::shared_timed_mutex &mutex_in) + std::shared_mutex &mutex; + DocumentDBMapExplorer(const DocumentDBMap &documentDBMap_in, std::shared_mutex &mutex_in) : documentDBMap(documentDBMap_in), mutex(mutex_in) {} void get_state(const vespalib::slime::Inserter &, bool) const override {} std::vector get_children_names() const override { - std::shared_lock guard(mutex); + std::shared_lock guard(mutex); std::vector names; for (const auto &item: documentDBMap) { names.push_back(item.first.getName()); @@ -861,7 +861,7 @@ struct DocumentDBMapExplorer : vespalib::StateExplorer { } std::unique_ptr get_child(vespalib::stringref name) const override { typedef std::unique_ptr Explorer_UP; - std::shared_lock guard(mutex); + std::shared_lock guard(mutex); auto result = documentDBMap.find(DocTypeName(vespalib::string(name))); if (result == documentDBMap.end()) { return Explorer_UP(nullptr); diff --git a/searchcore/src/vespa/searchcore/proton/server/proton.h b/searchcore/src/vespa/searchcore/proton/server/proton.h index 55fd3594463..45556319e78 100644 --- a/searchcore/src/vespa/searchcore/proton/server/proton.h +++ b/searchcore/src/vespa/searchcore/proton/server/proton.h @@ -86,7 +86,7 @@ private: }; const config::ConfigUri _configUri; - mutable std::shared_timed_mutex _mutex; + mutable std::shared_mutex _mutex; MetricsUpdateHook _metricsHook; std::unique_ptr _metricsEngine; ProtonFileHeaderContext _fileHeaderContext; -- cgit v1.2.3