aboutsummaryrefslogtreecommitdiffstats
path: root/searchcorespi
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2020-10-08 18:56:55 +0000
committerHenning Baldersheim <balder@yahoo-inc.com>2020-10-08 18:56:55 +0000
commit32286c1b4f19b0db0e899155dd26af8cde8a6b5b (patch)
tree26d715ea60d2bcb77e10e05985125241c8ef70f0 /searchcorespi
parent2e3515a187d0b3aae7ae1afd2708f011b9b8bf22 (diff)
Use std::mutex
Diffstat (limited to 'searchcorespi')
-rw-r--r--searchcorespi/src/vespa/searchcorespi/index/activediskindexes.cpp13
-rw-r--r--searchcorespi/src/vespa/searchcorespi/index/activediskindexes.h18
-rw-r--r--searchcorespi/src/vespa/searchcorespi/index/indexmaintainer.cpp5
-rw-r--r--searchcorespi/src/vespa/searchcorespi/index/indexmaintainer.h28
4 files changed, 32 insertions, 32 deletions
diff --git a/searchcorespi/src/vespa/searchcorespi/index/activediskindexes.cpp b/searchcorespi/src/vespa/searchcorespi/index/activediskindexes.cpp
index 7a590b66a8a..bec6f02324a 100644
--- a/searchcorespi/src/vespa/searchcorespi/index/activediskindexes.cpp
+++ b/searchcorespi/src/vespa/searchcorespi/index/activediskindexes.cpp
@@ -3,26 +3,27 @@
#include "activediskindexes.h"
#include <cassert>
-using std::set;
using vespalib::string;
-using vespalib::LockGuard;
namespace searchcorespi::index {
+ActiveDiskIndexes::ActiveDiskIndexes() = default;
+ActiveDiskIndexes::~ActiveDiskIndexes() = default;
+
void ActiveDiskIndexes::setActive(const string &index) {
- LockGuard lock(_lock);
+ std::lock_guard lock(_lock);
_active.insert(index);
}
void ActiveDiskIndexes::notActive(const string & index) {
- LockGuard lock(_lock);
- set<string>::iterator it = _active.find(index);
+ std::lock_guard lock(_lock);
+ auto it = _active.find(index);
assert(it != _active.end());
_active.erase(it);
}
bool ActiveDiskIndexes::isActive(const string &index) const {
- LockGuard lock(_lock);
+ std::lock_guard lock(_lock);
return _active.find(index) != _active.end();
}
diff --git a/searchcorespi/src/vespa/searchcorespi/index/activediskindexes.h b/searchcorespi/src/vespa/searchcorespi/index/activediskindexes.h
index dff25906559..c1c0e4e4d88 100644
--- a/searchcorespi/src/vespa/searchcorespi/index/activediskindexes.h
+++ b/searchcorespi/src/vespa/searchcorespi/index/activediskindexes.h
@@ -3,11 +3,10 @@
#pragma once
#include <vespa/vespalib/stllike/string.h>
-#include <vespa/vespalib/util/sync.h>
#include <set>
+#include <mutex>
-namespace searchcorespi {
-namespace index {
+namespace searchcorespi::index {
/**
* Class used to keep track of the set of active disk indexes in an index maintainer.
@@ -15,16 +14,17 @@ namespace index {
*/
class ActiveDiskIndexes {
std::multiset<vespalib::string> _active;
- vespalib::Lock _lock;
+ mutable std::mutex _lock;
public:
- typedef std::shared_ptr<ActiveDiskIndexes> SP;
-
+ using SP = std::shared_ptr<ActiveDiskIndexes>;
+ ActiveDiskIndexes();
+ ~ActiveDiskIndexes();
+ ActiveDiskIndexes(const ActiveDiskIndexes &) = delete;
+ ActiveDiskIndexes & operator = (const ActiveDiskIndexes &) = delete;
void setActive(const vespalib::string & index);
void notActive(const vespalib::string & index);
bool isActive(const vespalib::string & index) const;
};
-} // namespace index
-} // namespace searchcorespi
-
+}
diff --git a/searchcorespi/src/vespa/searchcorespi/index/indexmaintainer.cpp b/searchcorespi/src/vespa/searchcorespi/index/indexmaintainer.cpp
index 32dc2531061..c75a74ff141 100644
--- a/searchcorespi/src/vespa/searchcorespi/index/indexmaintainer.cpp
+++ b/searchcorespi/src/vespa/searchcorespi/index/indexmaintainer.cpp
@@ -41,7 +41,6 @@ using vespalib::makeTask;
using vespalib::string;
using vespalib::Closure0;
using vespalib::Executor;
-using vespalib::LockGuard;
using vespalib::Runnable;
namespace searchcorespi::index {
@@ -349,10 +348,12 @@ IndexMaintainer::loadDiskIndexes(const FusionSpec &spec, ISearchableIndexCollect
namespace {
+ using LockGuard = std::lock_guard<std::mutex>;
+
ISearchableIndexCollection::SP
getLeaf(const LockGuard &newSearchLock, const ISearchableIndexCollection::SP & is, bool warn=false)
{
- if (dynamic_cast<const WarmupIndexCollection *>(is.get()) != NULL) {
+ if (dynamic_cast<const WarmupIndexCollection *>(is.get()) != nullptr) {
if (warn) {
LOG(info, "Already warming up an index '%s'. Start using it immediately."
" This is an indication that you have configured your warmup interval too long.",
diff --git a/searchcorespi/src/vespa/searchcorespi/index/indexmaintainer.h b/searchcorespi/src/vespa/searchcorespi/index/indexmaintainer.h
index 671f87ff35b..5ff805b53f7 100644
--- a/searchcorespi/src/vespa/searchcorespi/index/indexmaintainer.h
+++ b/searchcorespi/src/vespa/searchcorespi/index/indexmaintainer.h
@@ -18,9 +18,6 @@
#include <vespa/searchcorespi/flush/flushstats.h>
#include <vespa/searchlib/attribute/fixedsourceselector.h>
#include <vespa/searchlib/common/serialnum.h>
-#include <vespa/vespalib/util/sync.h>
-#include <memory>
-#include <vector>
namespace document { class Document; }
@@ -74,6 +71,7 @@ class IndexMaintainer : public IIndexManager,
using FlushIds = std::vector<uint32_t>;
using FrozenMemoryIndexRefs = std::vector<FrozenMemoryIndexRef>;
using ISourceSelector = search::queryeval::ISourceSelector;
+ using LockGuard = std::lock_guard<std::mutex>;
const vespalib::string _base_dir;
const WarmupConfig _warmupConfig;
@@ -129,17 +127,17 @@ class IndexMaintainer : public IIndexManager,
* and pruning of removed fields, since this will trigger more retries for
* some of the operations.
*/
- vespalib::Lock _state_lock; // Outer lock (SL)
- vespalib::Lock _index_update_lock; // Inner lock (IUL)
- vespalib::Lock _new_search_lock; // Inner lock (NSL)
- vespalib::Lock _remove_lock; // Lock for removing indexes.
+ std::mutex _state_lock; // Outer lock (SL)
+ mutable std::mutex _index_update_lock; // Inner lock (IUL)
+ mutable std::mutex _new_search_lock; // Inner lock (NSL)
+ std::mutex _remove_lock; // Lock for removing indexes.
// Protected by SL + IUL
- FusionSpec _fusion_spec; // Protected by FL
- vespalib::Lock _fusion_lock; // Fusion spec lock (FL)
+ FusionSpec _fusion_spec; // Protected by FL
+ mutable std::mutex _fusion_lock; // Fusion spec lock (FL)
uint32_t _maxFlushed;
uint32_t _maxFrozen;
ChangeGens _changeGens; // Protected by SL + IUL
- vespalib::Lock _schemaUpdateLock; // Serialize rewrite of schema
+ std::mutex _schemaUpdateLock; // Serialize rewrite of schema
const search::TuneFileAttributes _tuneFileAttributes;
const IndexMaintainerContext _ctx;
IIndexMaintainerOperations &_operations;
@@ -179,8 +177,8 @@ class IndexMaintainer : public IIndexManager,
ISearchableIndexCollection::UP loadDiskIndexes(const FusionSpec &spec, ISearchableIndexCollection::UP sourceList);
void replaceSource(uint32_t sourceId, const IndexSearchable::SP &source);
void appendSource(uint32_t sourceId, const IndexSearchable::SP &source);
- void swapInNewIndex(vespalib::LockGuard & guard, ISearchableIndexCollection::SP indexes, IndexSearchable & source);
- ISearchableIndexCollection::UP createNewSourceCollection(const vespalib::LockGuard &newSearchLock);
+ void swapInNewIndex(LockGuard & guard, ISearchableIndexCollection::SP indexes, IndexSearchable & source);
+ ISearchableIndexCollection::UP createNewSourceCollection(const LockGuard &newSearchLock);
struct FlushArgs {
IMemoryIndex::SP old_index; // Last memory index
@@ -353,17 +351,17 @@ public:
}
IIndexCollection::SP getSourceCollection() const {
- vespalib::LockGuard lock(_new_search_lock);
+ LockGuard lock(_new_search_lock);
return _source_list;
}
searchcorespi::IndexSearchable::SP getSearchable() const override {
- vespalib::LockGuard lock(_new_search_lock);
+ LockGuard lock(_new_search_lock);
return _source_list;
}
search::SearchableStats getSearchableStats() const override {
- vespalib::LockGuard lock(_new_search_lock);
+ LockGuard lock(_new_search_lock);
return _source_list->getSearchableStats();
}