diff options
14 files changed, 43 insertions, 44 deletions
diff --git a/fastlib/src/vespa/fastlib/net/httpserver.cpp b/fastlib/src/vespa/fastlib/net/httpserver.cpp index a9bba95a8ff..0d1b75ec7fe 100644 --- a/fastlib/src/vespa/fastlib/net/httpserver.cpp +++ b/fastlib/src/vespa/fastlib/net/httpserver.cpp @@ -367,7 +367,7 @@ int Fast_HTTPServer::Start(void) int retCode = FASTLIB_SUCCESS; { - std::unique_lock<std::mutex> runningGuard(_runningMutex); + std::lock_guard<std::mutex> runningGuard(_runningMutex); if (!_isRunning) { // Try listening retCode = Listen(); @@ -391,7 +391,7 @@ int Fast_HTTPServer::Start(void) void Fast_HTTPServer::Stop(void) { { - std::unique_lock<std::mutex> runningGuard(_runningMutex); + std::lock_guard<std::mutex> runningGuard(_runningMutex); _stopSignalled = true; if (_acceptThread) { _acceptThread->SetBreakFlag(); @@ -407,7 +407,7 @@ Fast_HTTPServer::Stop(void) { bool Fast_HTTPServer::StopSignalled(void) { bool retVal; - std::unique_lock<std::mutex> runningGuard(_runningMutex); + std::lock_guard<std::mutex> runningGuard(_runningMutex); retVal = _stopSignalled; return retVal; } @@ -458,7 +458,7 @@ void Fast_HTTPServer::Run(FastOS_ThreadInterface *thisThread, void *params) Fast_Socket *mySocket; { - std::unique_lock<std::mutex> runningGuard(_runningMutex); + std::lock_guard<std::mutex> runningGuard(_runningMutex); _isRunning = true; _stopSignalled = false; } @@ -516,7 +516,7 @@ void Fast_HTTPServer::Run(FastOS_ThreadInterface *thisThread, void *params) _serverSocket.SetSocketEvent(NULL); } - std::unique_lock<std::mutex> runningGuard(_runningMutex); + std::lock_guard<std::mutex> runningGuard(_runningMutex); _isRunning = false; } @@ -1040,7 +1040,7 @@ void Fast_HTTPServer::HandleFileRequest(const string & url, Fast_HTTPConnection& void Fast_HTTPServer::SetBaseDir(const char *baseDir) { - std::unique_lock<std::mutex> runningGuard(_runningMutex); + std::lock_guard<std::mutex> runningGuard(_runningMutex); if (!_isRunning) { _baseDir = baseDir; @@ -1178,14 +1178,14 @@ void Fast_HTTPServer::OutputNotFound(Fast_HTTPConnection& conn, void Fast_HTTPServer::AddConnection(Fast_HTTPConnection* connection) { - std::unique_lock<std::mutex> connectionGuard(_connectionLock); + std::lock_guard<std::mutex> connectionGuard(_connectionLock); _connections.Insert(connection); } void Fast_HTTPServer::RemoveConnection(Fast_HTTPConnection* connection) { - std::unique_lock<std::mutex> connectionGuard(_connectionLock); + std::lock_guard<std::mutex> connectionGuard(_connectionLock); _connections.RemoveElement(connection); _connectionCond.notify_one(); } diff --git a/fastlib/src/vespa/fastlib/text/normwordfolder.cpp b/fastlib/src/vespa/fastlib/text/normwordfolder.cpp index f383ff85df5..ca1f260515f 100644 --- a/fastlib/src/vespa/fastlib/text/normwordfolder.cpp +++ b/fastlib/src/vespa/fastlib/text/normwordfolder.cpp @@ -29,7 +29,7 @@ Fast_NormalizeWordFolder::Setup(uint32_t flags) { // Only allow setting these when not initialized or initializing... { - std::unique_lock<std::mutex> initGuard(_initMutex); + std::lock_guard<std::mutex> initGuard(_initMutex); _doAccentRemoval = (DO_ACCENT_REMOVAL & flags) != 0; // _doSmallToNormalKana = (DO_SMALL_TO_NORMAL_KANA & flags) != 0; // _doKatakanaToHiragana = (DO_KATAKANA_TO_HIRAGANA & flags) != 0; @@ -48,7 +48,7 @@ Fast_NormalizeWordFolder::Initialize() { unsigned int i; if (!_isInitialized) { - std::unique_lock<std::mutex> initGuard(_initMutex); + std::lock_guard<std::mutex> initGuard(_initMutex); if (!_isInitialized) { for (i = 0; i < 128; i++) diff --git a/searchcore/src/tests/proton/proton_config_fetcher/proton_config_fetcher_test.cpp b/searchcore/src/tests/proton/proton_config_fetcher/proton_config_fetcher_test.cpp index 6c682ea33e9..b9059338f27 100644 --- a/searchcore/src/tests/proton/proton_config_fetcher/proton_config_fetcher_test.cpp +++ b/searchcore/src/tests/proton/proton_config_fetcher/proton_config_fetcher_test.cpp @@ -170,12 +170,12 @@ struct ProtonConfigOwner : public proton::IProtonConfigurer return getConfigured(); } virtual void reconfigure(std::shared_ptr<ProtonConfigSnapshot> cfg) override { - std::unique_lock<std::mutex> guard(_mutex); + std::lock_guard<std::mutex> guard(_mutex); _config.set(cfg); _configured = true; } bool getConfigured() const { - std::unique_lock<std::mutex> guard(_mutex); + std::lock_guard<std::mutex> guard(_mutex); return _configured; } BootstrapConfig::SP getBootstrapConfig() { diff --git a/searchcore/src/vespa/searchcore/fdispatch/common/search.cpp b/searchcore/src/vespa/searchcore/fdispatch/common/search.cpp index 7685ddcc328..7b060e793f6 100644 --- a/searchcore/src/vespa/searchcore/fdispatch/common/search.cpp +++ b/searchcore/src/vespa/searchcore/fdispatch/common/search.cpp @@ -165,7 +165,7 @@ void FastS_SyncSearchAdapter::DoneQuery(FastS_ISearch *, FastS_SearchContext) { - std::unique_lock<std::mutex> guard(_lock); + std::lock_guard<std::mutex> guard(_lock); _queryDone = true; if (_waitQuery) { _cond.notify_one(); @@ -177,7 +177,7 @@ void FastS_SyncSearchAdapter::DoneDocsums(FastS_ISearch *, FastS_SearchContext) { - std::unique_lock<std::mutex> guard(_lock); + std::lock_guard<std::mutex> guard(_lock); _docsumsDone = true; if (_waitDocsums) { _cond.notify_one(); diff --git a/searchcore/src/vespa/searchcore/fdispatch/search/engine_base.cpp b/searchcore/src/vespa/searchcore/fdispatch/search/engine_base.cpp index 83312a41875..24668db6024 100644 --- a/searchcore/src/vespa/searchcore/fdispatch/search/engine_base.cpp +++ b/searchcore/src/vespa/searchcore/fdispatch/search/engine_base.cpp @@ -112,7 +112,7 @@ void FastS_EngineBase::SlowQuery(double limit, double secs, bool silent) { { - std::unique_lock<std::mutex> engineGuard(_lock); + std::lock_guard<std::mutex> engineGuard(_lock); _stats._slowQueryCnt++; _stats._slowQuerySecs += secs; } @@ -127,7 +127,7 @@ void FastS_EngineBase::SlowDocsum(double limit, double secs) { { - std::unique_lock<std::mutex> engineGuard(_lock); + std::lock_guard<std::mutex> engineGuard(_lock); _stats._slowDocsumCnt++; _stats._slowDocsumSecs += secs; } @@ -173,7 +173,7 @@ FastS_EngineBase::SampleQueueLens() double queueLen; double activecnt; - std::unique_lock<std::mutex> engineGuard(_lock); + std::lock_guard<std::mutex> engineGuard(_lock); if (_stats._queueLenSampleCnt > 0) queueLen = (double) _stats._queueLenSampleAcc / (double) _stats._queueLenSampleCnt; else @@ -217,7 +217,7 @@ FastS_EngineBase::MarkBad(uint32_t badness) bool worse = false; { - std::unique_lock<std::mutex> engineGuard(_lock); + std::lock_guard<std::mutex> engineGuard(_lock); if (badness > _badness) { _badness = badness; worse = true; diff --git a/searchcore/src/vespa/searchcore/fdispatch/search/fnet_search.cpp b/searchcore/src/vespa/searchcore/fdispatch/search/fnet_search.cpp index 0cfbdc8b69a..85599b9e897 100644 --- a/searchcore/src/vespa/searchcore/fdispatch/search/fnet_search.cpp +++ b/searchcore/src/vespa/searchcore/fdispatch/search/fnet_search.cpp @@ -1077,7 +1077,7 @@ FastS_FNET_Search::Search(uint32_t searchOffset, // allow FNET responses while requests are being sent { - std::unique_lock<std::mutex> searchGuard(_lock); + std::lock_guard<std::mutex> searchGuard(_lock); ++_pendingQueries; // add Elephant query node to avoid early query done ++_queryNodes; // add Elephant query node to avoid early query done _FNET_mode = FNET_QUERY; @@ -1102,7 +1102,7 @@ FastS_FNET_Search::Search(uint32_t searchOffset, // finalize setup and check if query is still in progress bool done; { - std::unique_lock<std::mutex> searchGuard(_lock); + std::lock_guard<std::mutex> searchGuard(_lock); assert(_queryNodes >= _pendingQueries); for (uint32_t i: send_failed) { // conditional revert of state for failed nodes @@ -1398,7 +1398,7 @@ FastS_FNET_Search::GetDocsums(const FastS_hitresult *hits, uint32_t hitcnt) ConnectDocsumNodes(ignoreRow); bool done; { - std::unique_lock<std::mutex> searchGuard(_lock); + std::lock_guard<std::mutex> searchGuard(_lock); // patch in engine dependent features and send docsum requests diff --git a/searchcore/src/vespa/searchcore/fdispatch/search/nodemanager.cpp b/searchcore/src/vespa/searchcore/fdispatch/search/nodemanager.cpp index 6fddfae2ab0..4b272a615a6 100644 --- a/searchcore/src/vespa/searchcore/fdispatch/search/nodemanager.cpp +++ b/searchcore/src/vespa/searchcore/fdispatch/search/nodemanager.cpp @@ -125,7 +125,7 @@ FastS_NodeManager::CheckTempFail() _checkTempFailScheduled = false; tempfail = false; { - std::unique_lock<std::mutex> mangerGuard(_managerLock); + std::lock_guard<std::mutex> mangerGuard(_managerLock); FastS_DataSetCollection *dsc = PeekDataSetCollection(); for (unsigned int i = 0; i < dsc->GetMaxNumDataSets(); i++) { FastS_DataSetBase *ds; @@ -166,7 +166,7 @@ uint32_t FastS_NodeManager::SetPartMap(const PartitionsConfig& partmap, unsigned int waitms) { - std::unique_lock<std::mutex> configGuard(_configLock); + std::lock_guard<std::mutex> configGuard(_configLock); FastS_DataSetCollDesc *configDesc = new FastS_DataSetCollDesc(); if (!configDesc->ReadConfig(partmap)) { LOG(error, "NodeManager::SetPartMap: Failed to load configuration"); @@ -275,7 +275,7 @@ FastS_NodeManager::SetDataSetCollection(FastS_DataSetCollection *dsc) } else { { - std::unique_lock<std::mutex> managerGuard(_managerLock); + std::lock_guard<std::mutex> managerGuard(_managerLock); _gencnt++; gencnt = _gencnt; @@ -304,7 +304,7 @@ FastS_NodeManager::GetDataSetCollection() { FastS_DataSetCollection *ret; - std::unique_lock<std::mutex> managerGuard(_managerLock); + std::lock_guard<std::mutex> managerGuard(_managerLock); ret = _datasetCollection; FastS_assert(ret != NULL); ret->addRef(); @@ -320,8 +320,8 @@ FastS_NodeManager::ShutdownConfig() FastS_DataSetCollection *old_dsc; { - std::unique_lock<std::mutex> configGuard(_configLock); - std::unique_lock<std::mutex> managerGuard(_managerLock); + std::lock_guard<std::mutex> configGuard(_configLock); + std::lock_guard<std::mutex> managerGuard(_managerLock); _shutdown = true; // disallow SetPartMap dsc = _datasetCollection; _datasetCollection = new FastS_DataSetCollection(_appCtx); @@ -347,7 +347,7 @@ FastS_NodeManager::GetTotalPartitions() uint32_t ret; ret = 0; - std::unique_lock<std::mutex> managerGuard(_managerLock); + std::lock_guard<std::mutex> managerGuard(_managerLock); FastS_DataSetCollection *dsc = PeekDataSetCollection(); for (unsigned int i = 0; i < dsc->GetMaxNumDataSets(); i++) { FastS_DataSetBase *ds; @@ -429,7 +429,7 @@ FastS_NodeManager::CheckEvents(FastS_TimeKeeper *timeKeeper) FastS_DataSetCollection *tmp; { - std::unique_lock<std::mutex> managerGuard(_managerLock); + std::lock_guard<std::mutex> managerGuard(_managerLock); old_dsc = _oldDSCList; } diff --git a/searchcore/src/vespa/searchcore/proton/attribute/attribute_directory.cpp b/searchcore/src/vespa/searchcore/proton/attribute/attribute_directory.cpp index eac994bb339..f775f4443f8 100644 --- a/searchcore/src/vespa/searchcore/proton/attribute/attribute_directory.cpp +++ b/searchcore/src/vespa/searchcore/proton/attribute/attribute_directory.cpp @@ -56,7 +56,7 @@ AttributeDirectory::getDirName() const { std::shared_ptr<AttributeDiskLayout> diskLayout; { - std::unique_lock<std::mutex> guard(_mutex); + std::lock_guard<std::mutex> guard(_mutex); assert(!_diskLayout.expired()); diskLayout = _diskLayout.lock(); } @@ -204,7 +204,7 @@ void AttributeDirectory::detach() { assert(empty()); - std::unique_lock<std::mutex> guard(_mutex); + std::lock_guard<std::mutex> guard(_mutex); _diskLayout.reset(); } @@ -238,7 +238,7 @@ AttributeDirectory::tryGetWriter() bool AttributeDirectory::empty() const { - std::unique_lock<std::mutex> guard(_mutex); + std::lock_guard<std::mutex> guard(_mutex); return _snapInfo.snapshots().empty(); } diff --git a/searchcore/src/vespa/searchcore/proton/attribute/attributedisklayout.cpp b/searchcore/src/vespa/searchcore/proton/attribute/attributedisklayout.cpp index 1fcffa92cce..bb2f99d077b 100644 --- a/searchcore/src/vespa/searchcore/proton/attribute/attributedisklayout.cpp +++ b/searchcore/src/vespa/searchcore/proton/attribute/attributedisklayout.cpp @@ -59,7 +59,7 @@ AttributeDiskLayout::getAttributeDir(const vespalib::string &name) std::shared_ptr<AttributeDirectory> AttributeDiskLayout::createAttributeDir(const vespalib::string &name) { - std::unique_lock<std::shared_timed_mutex> guard(_mutex); + std::lock_guard<std::shared_timed_mutex> guard(_mutex); auto itr = _dirs.find(name); if (itr == _dirs.end()) { auto dir = std::make_shared<AttributeDirectory>(shared_from_this(), name); @@ -81,7 +81,7 @@ AttributeDiskLayout::removeAttributeDir(const vespalib::string &name, search::Se writer->invalidateOldSnapshots(serialNum); writer->removeInvalidSnapshots(); if (writer->removeDiskDir()) { - std::unique_lock<std::shared_timed_mutex> guard(_mutex); + std::lock_guard<std::shared_timed_mutex> guard(_mutex); auto itr = _dirs.find(name); assert(itr != _dirs.end()); assert(dir.get() == itr->second.get()); @@ -89,7 +89,7 @@ AttributeDiskLayout::removeAttributeDir(const vespalib::string &name, search::Se writer->detach(); } } else { - std::unique_lock<std::shared_timed_mutex> guard(_mutex); + std::lock_guard<std::shared_timed_mutex> 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/metrics/job_tracker.cpp b/searchcore/src/vespa/searchcore/proton/metrics/job_tracker.cpp index 753c84cd9b6..6d05ce8c57d 100644 --- a/searchcore/src/vespa/searchcore/proton/metrics/job_tracker.cpp +++ b/searchcore/src/vespa/searchcore/proton/metrics/job_tracker.cpp @@ -20,14 +20,14 @@ JobTracker::sampleLoad(time_point now, const std::lock_guard<std::mutex> &guard) void JobTracker::start() { - std::unique_lock<std::mutex> guard(_lock); + std::lock_guard<std::mutex> guard(_lock); _sampler.startJob(std::chrono::steady_clock::now()); } void JobTracker::end() { - std::unique_lock<std::mutex> guard(_lock); + std::lock_guard<std::mutex> guard(_lock); _sampler.endJob(std::chrono::steady_clock::now()); } diff --git a/searchcore/src/vespa/searchcore/proton/reference/document_db_reference_registry.cpp b/searchcore/src/vespa/searchcore/proton/reference/document_db_reference_registry.cpp index 75a20f9f8e5..68aaad3b557 100644 --- a/searchcore/src/vespa/searchcore/proton/reference/document_db_reference_registry.cpp +++ b/searchcore/src/vespa/searchcore/proton/reference/document_db_reference_registry.cpp @@ -30,7 +30,7 @@ DocumentDBReferenceRegistry::get(vespalib::stringref name) const std::shared_ptr<IDocumentDBReference> DocumentDBReferenceRegistry::tryGet(vespalib::stringref name) const { - std::unique_lock<std::mutex> guard(_lock); + std::lock_guard<std::mutex> guard(_lock); auto itr = _handlers.find(name); if (itr == _handlers.end()) { return std::shared_ptr<IDocumentDBReference>(); diff --git a/searchcore/src/vespa/searchcore/proton/server/pendinglidtracker.cpp b/searchcore/src/vespa/searchcore/proton/server/pendinglidtracker.cpp index 15283c170cc..79bf970aeac 100644 --- a/searchcore/src/vespa/searchcore/proton/server/pendinglidtracker.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/pendinglidtracker.cpp @@ -6,7 +6,6 @@ namespace proton { -using LockGuard = std::unique_lock<std::mutex>; PendingLidTracker::PendingLidTracker() : _mutex(), _cond(), @@ -19,12 +18,12 @@ PendingLidTracker::~PendingLidTracker() { void PendingLidTracker::produce(uint32_t lid) { - LockGuard guard(_mutex); + std::lock_guard<std::mutex> guard(_mutex); _pending[lid]++; } void PendingLidTracker::consume(uint32_t lid) { - LockGuard guard(_mutex); + std::lock_guard<std::mutex> guard(_mutex); auto found = _pending.find(lid); assert (found != _pending.end()); assert (found->second > 0); @@ -38,7 +37,7 @@ PendingLidTracker::consume(uint32_t lid) { void PendingLidTracker::waitForConsumedLid(uint32_t lid) { - LockGuard guard(_mutex); + std::unique_lock<std::mutex> guard(_mutex); while (_pending.find(lid) != _pending.end()) { _cond.wait(guard); } diff --git a/searchlib/src/tests/postinglistbm/andstress.cpp b/searchlib/src/tests/postinglistbm/andstress.cpp index 736d53508b4..40f919509e8 100644 --- a/searchlib/src/tests/postinglistbm/andstress.cpp +++ b/searchlib/src/tests/postinglistbm/andstress.cpp @@ -280,7 +280,7 @@ AndStressMaster::Task * AndStressMaster::getTask() { Task *result = NULL; - std::unique_lock<std::mutex> taskGuard(_taskLock); + std::lock_guard<std::mutex> taskGuard(_taskLock); if (_taskIdx < _tasks.size()) { result = &_tasks[_taskIdx]; ++_taskIdx; diff --git a/staging_vespalib/src/vespa/vespalib/util/clock.cpp b/staging_vespalib/src/vespa/vespalib/util/clock.cpp index b19b067afa9..c9768417914 100644 --- a/staging_vespalib/src/vespa/vespalib/util/clock.cpp +++ b/staging_vespalib/src/vespa/vespalib/util/clock.cpp @@ -45,7 +45,7 @@ void Clock::Run(FastOS_ThreadInterface *thread, void *arguments) void Clock::stop(void) { - std::unique_lock<std::mutex> guard(_lock); + std::lock_guard<std::mutex> guard(_lock); _stop = true; _cond.notify_all(); } |