summaryrefslogtreecommitdiffstats
path: root/searchcore
diff options
context:
space:
mode:
Diffstat (limited to 'searchcore')
-rw-r--r--searchcore/src/vespa/searchcore/proton/matchengine/matchengine.cpp12
-rw-r--r--searchcore/src/vespa/searchcore/proton/matchengine/matchengine.h3
-rw-r--r--searchcore/src/vespa/searchcore/proton/summaryengine/summaryengine.cpp21
3 files changed, 14 insertions, 22 deletions
diff --git a/searchcore/src/vespa/searchcore/proton/matchengine/matchengine.cpp b/searchcore/src/vespa/searchcore/proton/matchengine/matchengine.cpp
index 96ad422009c..83466cd51ad 100644
--- a/searchcore/src/vespa/searchcore/proton/matchengine/matchengine.cpp
+++ b/searchcore/src/vespa/searchcore/proton/matchengine/matchengine.cpp
@@ -62,7 +62,7 @@ MatchEngine::close()
{
LOG(debug, "Closing search interface.");
{
- vespalib::LockGuard guard(_lock);
+ std::lock_guard<std::mutex> guard(_lock);
_closed = true;
}
@@ -74,21 +74,21 @@ ISearchHandler::SP
MatchEngine::putSearchHandler(const DocTypeName &docTypeName,
const ISearchHandler::SP &searchHandler)
{
- vespalib::LockGuard guard(_lock);
+ std::lock_guard<std::mutex> guard(_lock);
return _handlers.putHandler(docTypeName, searchHandler);
}
ISearchHandler::SP
MatchEngine::getSearchHandler(const DocTypeName &docTypeName)
{
- vespalib::LockGuard guard(_lock);
+ std::lock_guard<std::mutex> guard(_lock);
return _handlers.getHandler(docTypeName);
}
ISearchHandler::SP
MatchEngine::removeSearchHandler(const DocTypeName &docTypeName)
{
- vespalib::LockGuard guard(_lock);
+ std::lock_guard<std::mutex> guard(_lock);
return _handlers.removeHandler(docTypeName);
}
@@ -121,7 +121,7 @@ MatchEngine::performSearch(search::engine::SearchRequest::Source req,
ISearchHandler::SP searchHandler;
vespalib::SimpleThreadBundle::UP threadBundle = _threadBundlePool.obtain();
{ // try to find the match handler corresponding to the specified search doc type
- vespalib::LockGuard guard(_lock);
+ std::lock_guard<std::mutex> guard(_lock);
DocTypeName docTypeName(*req.get());
searchHandler = _handlers.getHandler(docTypeName);
}
@@ -130,7 +130,7 @@ MatchEngine::performSearch(search::engine::SearchRequest::Source req,
} else {
HandlerMap<ISearchHandler>::Snapshot::UP snapshot;
{
- vespalib::LockGuard guard(_lock);
+ std::lock_guard<std::mutex> guard(_lock);
snapshot = _handlers.snapshot();
}
if (snapshot->valid()) {
diff --git a/searchcore/src/vespa/searchcore/proton/matchengine/matchengine.h b/searchcore/src/vespa/searchcore/proton/matchengine/matchengine.h
index 3055bbfb814..e27f1789ed3 100644
--- a/searchcore/src/vespa/searchcore/proton/matchengine/matchengine.h
+++ b/searchcore/src/vespa/searchcore/proton/matchengine/matchengine.h
@@ -9,6 +9,7 @@
#include <vespa/vespalib/net/state_explorer.h>
#include <vespa/vespalib/util/threadstackexecutor.h>
#include <vespa/vespalib/util/simple_thread_bundle.h>
+#include <mutex>
namespace proton {
@@ -16,7 +17,7 @@ class MatchEngine : public search::engine::SearchServer,
public vespalib::StateExplorer
{
private:
- vespalib::Lock _lock;
+ std::mutex _lock;
const uint32_t _distributionKey;
bool _closed;
HandlerMap<ISearchHandler> _handlers;
diff --git a/searchcore/src/vespa/searchcore/proton/summaryengine/summaryengine.cpp b/searchcore/src/vespa/searchcore/proton/summaryengine/summaryengine.cpp
index 560510ce744..cda1d0103c7 100644
--- a/searchcore/src/vespa/searchcore/proton/summaryengine/summaryengine.cpp
+++ b/searchcore/src/vespa/searchcore/proton/summaryengine/summaryengine.cpp
@@ -1,6 +1,5 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include "summaryengine.h"
-#include <vespa/vespalib/util/exceptions.h>
#include <vespa/log/log.h>
LOG_SETUP(".proton.summaryengine.summaryengine");
@@ -17,9 +16,7 @@ private:
DocsumRequest::Source _request;
public:
- DocsumTask(SummaryEngine & engine,
- DocsumRequest::Source request,
- DocsumClient & client)
+ DocsumTask(SummaryEngine & engine, DocsumRequest::Source request, DocsumClient & client)
: _engine(engine),
_client(client),
_request(std::move(request))
@@ -62,8 +59,7 @@ SummaryEngine::close()
}
ISearchHandler::SP
-SummaryEngine::putSearchHandler(const DocTypeName &docTypeName,
- const ISearchHandler::SP & searchHandler)
+SummaryEngine::putSearchHandler(const DocTypeName &docTypeName, const ISearchHandler::SP & searchHandler)
{
vespalib::LockGuard guard(_lock);
return _handlers.putHandler(docTypeName, searchHandler);
@@ -72,6 +68,7 @@ SummaryEngine::putSearchHandler(const DocTypeName &docTypeName,
ISearchHandler::SP
SummaryEngine::getSearchHandler(const DocTypeName &docTypeName)
{
+ vespalib::LockGuard guard(_lock);
return _handlers.getHandler(docTypeName);
}
@@ -101,17 +98,11 @@ SummaryEngine::getDocsums(DocsumRequest::Source request, DocsumClient & client)
DocsumReply::UP
SummaryEngine::getDocsums(DocsumRequest::UP req)
{
- DocsumReply::UP reply;
- reply.reset(new DocsumReply());
+ DocsumReply::UP reply = std::make_unique<DocsumReply>();
if (req) {
- ISearchHandler::SP searchHandler;
- { // try to find the summary handler corresponding to the specified search doc type
- vespalib::LockGuard guard(_lock);
- DocTypeName docTypeName(*req);
- searchHandler = _handlers.getHandler(docTypeName);
- }
- if (searchHandler.get() != NULL) {
+ ISearchHandler::SP searchHandler = getSearchHandler(DocTypeName(*req));
+ if (searchHandler) {
reply = searchHandler->getDocsums(*req);
} else {
vespalib::Sequence<ISearchHandler*>::UP snapshot;