summaryrefslogtreecommitdiffstats
path: root/searchcore
diff options
context:
space:
mode:
authorTor Egge <Tor.Egge@oath.com>2017-12-11 12:03:41 +0000
committerTor Egge <Tor.Egge@oath.com>2017-12-11 12:03:41 +0000
commit1086500f61605b2ecaa2ac95dc446de71a0e52c1 (patch)
treee0aa8bb4ee38d7dc5f1e59d1118d6243726f0c22 /searchcore
parentc64cebe292f68fc37864827a54751123aec0a5e9 (diff)
Use standard locking in searchcore/proton/server (pass 1).
Diffstat (limited to 'searchcore')
-rw-r--r--searchcore/src/vespa/searchcore/proton/server/documentretrieverbase.cpp4
-rw-r--r--searchcore/src/vespa/searchcore/proton/server/documentretrieverbase.h4
-rw-r--r--searchcore/src/vespa/searchcore/proton/server/feedhandler.cpp14
-rw-r--r--searchcore/src/vespa/searchcore/proton/server/feedhandler.h7
-rw-r--r--searchcore/src/vespa/searchcore/proton/server/memoryflush.cpp4
-rw-r--r--searchcore/src/vespa/searchcore/proton/server/memoryflush.h4
-rw-r--r--searchcore/src/vespa/searchcore/proton/server/simpleflush.h1
-rw-r--r--searchcore/src/vespa/searchcore/proton/server/visibilityhandler.cpp6
-rw-r--r--searchcore/src/vespa/searchcore/proton/server/visibilityhandler.h7
9 files changed, 24 insertions, 27 deletions
diff --git a/searchcore/src/vespa/searchcore/proton/server/documentretrieverbase.cpp b/searchcore/src/vespa/searchcore/proton/server/documentretrieverbase.cpp
index 0cea30385c3..d06319ae7f9 100644
--- a/searchcore/src/vespa/searchcore/proton/server/documentretrieverbase.cpp
+++ b/searchcore/src/vespa/searchcore/proton/server/documentretrieverbase.cpp
@@ -72,7 +72,7 @@ CachedSelect::SP
DocumentRetrieverBase::parseSelect(const vespalib::string &selection) const
{
{
- vespalib::LockGuard guard(_lock);
+ std::lock_guard<std::mutex> guard(_lock);
if (_selectCache.hasKey(selection))
return _selectCache[selection];
}
@@ -86,7 +86,7 @@ DocumentRetrieverBase::parseSelect(const vespalib::string &selection) const
getAttrMgr(),
_hasFields);
- vespalib::LockGuard guard(_lock);
+ std::lock_guard<std::mutex> guard(_lock);
if (_selectCache.hasKey(selection))
return _selectCache[selection];
_selectCache.insert(selection, nselect);
diff --git a/searchcore/src/vespa/searchcore/proton/server/documentretrieverbase.h b/searchcore/src/vespa/searchcore/proton/server/documentretrieverbase.h
index 3a0752e4c95..53341e0d335 100644
--- a/searchcore/src/vespa/searchcore/proton/server/documentretrieverbase.h
+++ b/searchcore/src/vespa/searchcore/proton/server/documentretrieverbase.h
@@ -7,7 +7,7 @@
#include <vespa/document/fieldvalue/document.h>
#include <vespa/vespalib/stllike/lrucache_map.h>
#include <vespa/searchlib/attribute/iattributemanager.h>
-#include <vespa/vespalib/util/sync.h>
+#include <mutex>
namespace proton {
@@ -20,7 +20,7 @@ class DocumentRetrieverBase : public IDocumentRetriever
using SelectCache = vespalib::lrucache_map<vespalib::LruParam<vespalib::string, CachedSelect::SP>>;
mutable SelectCache _selectCache;
- vespalib::Lock _lock;
+ mutable std::mutex _lock;
document::Document::UP _emptyDoc;
const bool _hasFields;
diff --git a/searchcore/src/vespa/searchcore/proton/server/feedhandler.cpp b/searchcore/src/vespa/searchcore/proton/server/feedhandler.cpp
index 2d8368e091b..c9b3df5a6ed 100644
--- a/searchcore/src/vespa/searchcore/proton/server/feedhandler.cpp
+++ b/searchcore/src/vespa/searchcore/proton/server/feedhandler.cpp
@@ -33,8 +33,6 @@ using vespalib::Executor;
using vespalib::IllegalStateException;
using vespalib::makeLambdaTask;
using vespalib::make_string;
-using vespalib::MonitorGuard;
-using vespalib::LockGuard;
using std::make_unique;
using std::make_shared;
@@ -81,7 +79,7 @@ void
FeedHandler::doHandleOperation(FeedToken token, FeedOperation::UP op)
{
assert(_writeService.master().isCurrentThread());
- LockGuard guard(_feedLock);
+ std::lock_guard<std::mutex> guard(_feedLock);
_feedState->handleOperation(std::move(token), std::move(op));
}
@@ -284,7 +282,7 @@ FeedHandler::getFeedState() const
{
FeedState::SP state;
{
- LockGuard guard(_feedLock);
+ std::lock_guard<std::mutex> guard(_feedLock);
state = _feedState;
}
return state;
@@ -294,13 +292,13 @@ FeedHandler::getFeedState() const
void
FeedHandler::changeFeedState(FeedState::SP newState)
{
- LockGuard guard(_feedLock);
+ std::lock_guard<std::mutex> guard(_feedLock);
changeFeedState(std::move(newState), guard);
}
void
-FeedHandler::changeFeedState(FeedState::SP newState, const LockGuard &)
+FeedHandler::changeFeedState(FeedState::SP newState, const std::lock_guard<std::mutex> &)
{
LOG(debug, "Change feed state from '%s' -> '%s'", _feedState->getName().c_str(), newState->getName().c_str());
_feedState = newState;
@@ -591,7 +589,7 @@ void
FeedHandler::syncTls(SerialNum syncTo)
{
{
- LockGuard guard(_syncLock);
+ std::lock_guard<std::mutex> guard(_syncLock);
if (_syncedSerialNum >= syncTo)
return;
}
@@ -600,7 +598,7 @@ FeedHandler::syncTls(SerialNum syncTo)
}
SerialNum syncedTo(_tlsWriter.sync(syncTo));
{
- LockGuard guard(_syncLock);
+ std::lock_guard<std::mutex> guard(_syncLock);
if (_syncedSerialNum < syncedTo)
_syncedSerialNum = syncedTo;
}
diff --git a/searchcore/src/vespa/searchcore/proton/server/feedhandler.h b/searchcore/src/vespa/searchcore/proton/server/feedhandler.h
index 8c28fcdc1ea..171462a6c13 100644
--- a/searchcore/src/vespa/searchcore/proton/server/feedhandler.h
+++ b/searchcore/src/vespa/searchcore/proton/server/feedhandler.h
@@ -13,6 +13,7 @@
#include <vespa/searchcore/proton/common/doctypename.h>
#include <vespa/searchcore/proton/common/feedtoken.h>
#include <vespa/searchlib/transactionlog/translogclient.h>
+#include <mutex>
namespace searchcorespi { namespace index { class IThreadingService; } }
@@ -85,12 +86,12 @@ private:
SerialNum _serialNum;
SerialNum _prunedSerialNum;
bool _delayedPrune;
- vespalib::Lock _feedLock;
+ mutable std::mutex _feedLock;
FeedStateSP _feedState;
// used by master write thread tasks
IFeedView *_activeFeedView;
bucketdb::IBucketDBHandler *_bucketDBHandler;
- vespalib::Lock _syncLock;
+ std::mutex _syncLock;
SerialNum _syncedSerialNum;
bool _allowSync; // Sanity check
@@ -129,7 +130,7 @@ private:
FeedStateSP getFeedState() const;
void changeFeedState(FeedStateSP newState);
- void changeFeedState(FeedStateSP newState, const vespalib::LockGuard &feedGuard);
+ void changeFeedState(FeedStateSP newState, const std::lock_guard<std::mutex> &feedGuard);
public:
FeedHandler(const FeedHandler &) = delete;
FeedHandler & operator = (const FeedHandler &) = delete;
diff --git a/searchcore/src/vespa/searchcore/proton/server/memoryflush.cpp b/searchcore/src/vespa/searchcore/proton/server/memoryflush.cpp
index ea787868f18..7d97cc4030a 100644
--- a/searchcore/src/vespa/searchcore/proton/server/memoryflush.cpp
+++ b/searchcore/src/vespa/searchcore/proton/server/memoryflush.cpp
@@ -90,14 +90,14 @@ MemoryFlush::~MemoryFlush() { }
MemoryFlush::Config
MemoryFlush::getConfig() const
{
- vespalib::LockGuard guard(_lock);
+ std::lock_guard<std::mutex> guard(_lock);
return _config;
}
void
MemoryFlush::setConfig(const Config &config)
{
- vespalib::LockGuard guard(_lock);
+ std::lock_guard<std::mutex> guard(_lock);
_config = config;
}
diff --git a/searchcore/src/vespa/searchcore/proton/server/memoryflush.h b/searchcore/src/vespa/searchcore/proton/server/memoryflush.h
index 552a406aad9..7e9bba59b25 100644
--- a/searchcore/src/vespa/searchcore/proton/server/memoryflush.h
+++ b/searchcore/src/vespa/searchcore/proton/server/memoryflush.h
@@ -2,7 +2,7 @@
#pragma once
#include <vespa/searchcore/proton/flushengine/iflushstrategy.h>
-#include <vespa/vespalib/util/sync.h>
+#include <mutex>
namespace proton {
@@ -39,7 +39,7 @@ public:
private:
/// Needed as flushDone is called in different context from the rest
- vespalib::Lock _lock;
+ mutable std::mutex _lock;
Config _config;
/// The time when the strategy was started.
fastos::TimeStamp _startTime;
diff --git a/searchcore/src/vespa/searchcore/proton/server/simpleflush.h b/searchcore/src/vespa/searchcore/proton/server/simpleflush.h
index 71dd629bdd1..c1f6e689eaa 100644
--- a/searchcore/src/vespa/searchcore/proton/server/simpleflush.h
+++ b/searchcore/src/vespa/searchcore/proton/server/simpleflush.h
@@ -2,7 +2,6 @@
#pragma once
#include <vespa/searchcore/proton/flushengine/iflushstrategy.h>
-#include <vespa/vespalib/util/sync.h>
namespace proton {
diff --git a/searchcore/src/vespa/searchcore/proton/server/visibilityhandler.cpp b/searchcore/src/vespa/searchcore/proton/server/visibilityhandler.cpp
index 430f61eed1d..dd12a5cfd3d 100644
--- a/searchcore/src/vespa/searchcore/proton/server/visibilityhandler.cpp
+++ b/searchcore/src/vespa/searchcore/proton/server/visibilityhandler.cpp
@@ -26,7 +26,7 @@ void VisibilityHandler::commit()
if (_writeService.master().isCurrentThread()) {
performCommit(true);
} else {
- LockGuard guard(_lock);
+ std::lock_guard<std::mutex> guard(_lock);
startCommit(guard, true);
}
}
@@ -38,7 +38,7 @@ void VisibilityHandler::commitAndWait()
if (_writeService.master().isCurrentThread()) {
performCommit(false);
} else {
- LockGuard guard(_lock);
+ std::lock_guard<std::mutex> guard(_lock);
if (startCommit(guard, false)) {
_writeService.master().sync();
}
@@ -50,7 +50,7 @@ void VisibilityHandler::commitAndWait()
_writeService.summary().sync();
}
-bool VisibilityHandler::startCommit(const LockGuard &unused, bool force)
+bool VisibilityHandler::startCommit(const std::lock_guard<std::mutex> &unused, bool force)
{
(void) unused;
SerialNum current = _serial.getSerialNum();
diff --git a/searchcore/src/vespa/searchcore/proton/server/visibilityhandler.h b/searchcore/src/vespa/searchcore/proton/server/visibilityhandler.h
index 6de6b0721d6..6ba2b640fce 100644
--- a/searchcore/src/vespa/searchcore/proton/server/visibilityhandler.h
+++ b/searchcore/src/vespa/searchcore/proton/server/visibilityhandler.h
@@ -7,6 +7,7 @@
#include <vespa/searchcore/proton/server/igetserialnum.h>
#include <vespa/searchcorespi/index/ithreadingservice.h>
#include <vespa/vespalib/util/varholder.h>
+#include <mutex>
namespace proton {
@@ -16,11 +17,9 @@ namespace proton {
**/
class VisibilityHandler : public ICommitable
{
- typedef vespalib::LockGuard LockGuard;
typedef fastos::TimeStamp TimeStamp;
using IThreadingService = searchcorespi::index::IThreadingService;
typedef vespalib::ThreadExecutor ThreadExecutor;
- typedef vespalib::Lock Lock;
typedef vespalib::VarHolder<IFeedView::SP> FeedViewHolder;
public:
typedef search::SerialNum SerialNum;
@@ -32,14 +31,14 @@ public:
void commit() override;
virtual void commitAndWait() override;
private:
- bool startCommit(const LockGuard &unused, bool force);
+ bool startCommit(const std::lock_guard<std::mutex> &unused, bool force);
void performCommit(bool force);
const IGetSerialNum & _serial;
IThreadingService & _writeService;
const FeedViewHolder & _feedView;
TimeStamp _visibilityDelay;
SerialNum _lastCommitSerialNum;
- Lock _lock;
+ std::mutex _lock;
};
}