summaryrefslogtreecommitdiffstats
path: root/searchcore
diff options
context:
space:
mode:
authorTor Egge <Tor.Egge@broadpark.no>2017-11-12 21:11:27 +0100
committerTor Egge <Tor.Egge@broadpark.no>2017-11-13 11:27:39 +0100
commit59f5ccf748a6e2d6f8e4b7565f106594e1d057f3 (patch)
treee854205e3ca4e990c348e76a7ce7f536f1d82802 /searchcore
parentb0e46e757b0fa7760b20d68bb22f6f8933882301 (diff)
Use std::lock_guard instead of std::unique_lock.
Diffstat (limited to 'searchcore')
-rw-r--r--searchcore/src/tests/proton/proton_config_fetcher/proton_config_fetcher_test.cpp4
-rw-r--r--searchcore/src/vespa/searchcore/fdispatch/common/search.cpp4
-rw-r--r--searchcore/src/vespa/searchcore/fdispatch/search/engine_base.cpp8
-rw-r--r--searchcore/src/vespa/searchcore/fdispatch/search/fnet_search.cpp6
-rw-r--r--searchcore/src/vespa/searchcore/fdispatch/search/nodemanager.cpp16
-rw-r--r--searchcore/src/vespa/searchcore/proton/attribute/attribute_directory.cpp6
-rw-r--r--searchcore/src/vespa/searchcore/proton/attribute/attributedisklayout.cpp6
-rw-r--r--searchcore/src/vespa/searchcore/proton/metrics/job_tracker.cpp4
-rw-r--r--searchcore/src/vespa/searchcore/proton/reference/document_db_reference_registry.cpp2
-rw-r--r--searchcore/src/vespa/searchcore/proton/server/pendinglidtracker.cpp7
10 files changed, 31 insertions, 32 deletions
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);
}