summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--documentapi/src/vespa/documentapi/messagebus/routablerepository.cpp6
-rw-r--r--documentapi/src/vespa/documentapi/messagebus/routablerepository.h10
-rw-r--r--documentapi/src/vespa/documentapi/messagebus/routingpolicyrepository.cpp4
-rw-r--r--documentapi/src/vespa/documentapi/messagebus/routingpolicyrepository.h6
-rw-r--r--messagebus/src/vespa/messagebus/messagebus.cpp13
-rw-r--r--messagebus/src/vespa/messagebus/messagebus.h3
-rw-r--r--messagebus/src/vespa/messagebus/network/rpcnetwork.cpp2
-rw-r--r--messagebus/src/vespa/messagebus/network/rpcnetwork.h4
-rw-r--r--messagebus/src/vespa/messagebus/protocolrepository.cpp4
-rw-r--r--messagebus/src/vespa/messagebus/protocolrepository.h4
-rw-r--r--messagebus/src/vespa/messagebus/sequencer.cpp6
-rw-r--r--messagebus/src/vespa/messagebus/sequencer.h6
-rw-r--r--messagebus_test/src/tests/speed/cpp-client.cpp8
-rw-r--r--searchlib/src/vespa/searchlib/fef/tablemanager.cpp23
-rw-r--r--searchlib/src/vespa/searchlib/fef/tablemanager.h13
15 files changed, 50 insertions, 62 deletions
diff --git a/documentapi/src/vespa/documentapi/messagebus/routablerepository.cpp b/documentapi/src/vespa/documentapi/messagebus/routablerepository.cpp
index c7f3401d3e1..6ed33cda060 100644
--- a/documentapi/src/vespa/documentapi/messagebus/routablerepository.cpp
+++ b/documentapi/src/vespa/documentapi/messagebus/routablerepository.cpp
@@ -109,7 +109,7 @@ void
RoutableRepository::putFactory(const vespalib::VersionSpecification &version,
uint32_t type, IRoutableFactory::SP factory)
{
- vespalib::LockGuard guard(_lock);
+ std::lock_guard guard(_lock);
if (_factoryTypes[type].putFactory(version, factory)) {
_cache.clear();
}
@@ -118,7 +118,7 @@ RoutableRepository::putFactory(const vespalib::VersionSpecification &version,
IRoutableFactory::SP
RoutableRepository::getFactory(const vespalib::Version &version, uint32_t type) const
{
- vespalib::LockGuard guard(_lock);
+ std::lock_guard guard(_lock);
CacheKey cacheKey(version, type);
FactoryCache::const_iterator cit = _cache.find(cacheKey);
if (cit != _cache.end()) {
@@ -139,7 +139,7 @@ RoutableRepository::getFactory(const vespalib::Version &version, uint32_t type)
uint32_t
RoutableRepository::getRoutableTypes(const vespalib::Version &version, std::vector<uint32_t> &out) const
{
- vespalib::LockGuard guard(_lock);
+ std::lock_guard guard(_lock);
for (const auto & type : _factoryTypes) {
if (type.second.getFactory(version)) {
out.push_back(type.first);
diff --git a/documentapi/src/vespa/documentapi/messagebus/routablerepository.h b/documentapi/src/vespa/documentapi/messagebus/routablerepository.h
index f4bddad45b4..7e73f3929b8 100644
--- a/documentapi/src/vespa/documentapi/messagebus/routablerepository.h
+++ b/documentapi/src/vespa/documentapi/messagebus/routablerepository.h
@@ -1,11 +1,11 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#pragma once
-#include <map>
+#include "iroutablefactory.h"
#include <vespa/messagebus/blobref.h>
-#include <vespa/vespalib/util/sync.h>
#include <vespa/vespalib/component/versionspecification.h>
-#include "iroutablefactory.h"
+#include <mutex>
+#include <map>
namespace documentapi {
@@ -37,7 +37,7 @@ private:
typedef std::map<CacheKey, IRoutableFactory::SP> FactoryCache;
typedef std::map<uint32_t, VersionMap> TypeMap;
- vespalib::Lock _lock;
+ mutable std::mutex _lock;
TypeMap _factoryTypes;
mutable FactoryCache _cache;
const LoadTypeSet& _loadTypes;
@@ -48,7 +48,7 @@ public:
/**
* Constructs a new routable repository.
*/
- RoutableRepository(const LoadTypeSet& loadTypes);
+ explicit RoutableRepository(const LoadTypeSet& loadTypes);
/**
* Decodes a {@link Routable} from the given byte array. This uses the content of the byte array to
diff --git a/documentapi/src/vespa/documentapi/messagebus/routingpolicyrepository.cpp b/documentapi/src/vespa/documentapi/messagebus/routingpolicyrepository.cpp
index 3c73cda786d..c21d8e97880 100644
--- a/documentapi/src/vespa/documentapi/messagebus/routingpolicyrepository.cpp
+++ b/documentapi/src/vespa/documentapi/messagebus/routingpolicyrepository.cpp
@@ -17,14 +17,14 @@ RoutingPolicyRepository::RoutingPolicyRepository() :
void
RoutingPolicyRepository::putFactory(const string &name, IRoutingPolicyFactory::SP factory)
{
- vespalib::LockGuard guard(_lock);
+ std::lock_guard guard(_lock);
_factories[name] = factory;
}
IRoutingPolicyFactory::SP
RoutingPolicyRepository::getFactory(const string &name) const
{
- vespalib::LockGuard guard(_lock);
+ std::lock_guard guard(_lock);
FactoryMap::const_iterator it = _factories.find(name);
if (it != _factories.end()) {
return it->second;
diff --git a/documentapi/src/vespa/documentapi/messagebus/routingpolicyrepository.h b/documentapi/src/vespa/documentapi/messagebus/routingpolicyrepository.h
index ca6057ef8b1..beeb176c88b 100644
--- a/documentapi/src/vespa/documentapi/messagebus/routingpolicyrepository.h
+++ b/documentapi/src/vespa/documentapi/messagebus/routingpolicyrepository.h
@@ -2,8 +2,8 @@
#pragma once
#include "iroutingpolicyfactory.h"
-#include <vespa/vespalib/util/sync.h>
#include <map>
+#include <mutex>
namespace documentapi {
@@ -11,8 +11,8 @@ class RoutingPolicyRepository {
private:
typedef std::map<string, IRoutingPolicyFactory::SP> FactoryMap;
- vespalib::Lock _lock;
- FactoryMap _factories;
+ mutable std::mutex _lock;
+ FactoryMap _factories;
public:
RoutingPolicyRepository(const RoutingPolicyRepository &) = delete;
diff --git a/messagebus/src/vespa/messagebus/messagebus.cpp b/messagebus/src/vespa/messagebus/messagebus.cpp
index c3d6b28b318..ce60f1a3969 100644
--- a/messagebus/src/vespa/messagebus/messagebus.cpp
+++ b/messagebus/src/vespa/messagebus/messagebus.cpp
@@ -13,7 +13,6 @@
#include <vespa/log/log.h>
LOG_SETUP(".messagebus");
-using vespalib::LockGuard;
using vespalib::make_string;
using namespace std::chrono_literals;
@@ -201,7 +200,7 @@ MessageBus::createIntermediateSession(const string &name,
IntermediateSession::UP
MessageBus::createIntermediateSession(const IntermediateSessionParams &params)
{
- LockGuard guard(_lock);
+ std::lock_guard guard(_lock);
IntermediateSession::UP ret(new IntermediateSession(*this, params));
_sessions[params.getName()] = ret.get();
if (params.getBroadcastName()) {
@@ -224,7 +223,7 @@ MessageBus::createDestinationSession(const string &name,
DestinationSession::UP
MessageBus::createDestinationSession(const DestinationSessionParams &params)
{
- LockGuard guard(_lock);
+ std::lock_guard guard(_lock);
DestinationSession::UP ret(new DestinationSession(*this, params));
_sessions[params.getName()] = ret.get();
if (params.getBroadcastName()) {
@@ -236,7 +235,7 @@ MessageBus::createDestinationSession(const DestinationSessionParams &params)
void
MessageBus::unregisterSession(const string &sessionName)
{
- LockGuard guard(_lock);
+ std::lock_guard guard(_lock);
_network.unregisterSession(sessionName);
_sessions.erase(sessionName);
}
@@ -245,7 +244,7 @@ RoutingTable::SP
MessageBus::getRoutingTable(const string &protocol)
{
typedef std::map<string, RoutingTable::SP>::iterator ITR;
- LockGuard guard(_lock);
+ std::lock_guard guard(_lock);
ITR itr = _routingTables.find(protocol);
if (itr == _routingTables.end()) {
return RoutingTable::SP(); // not found
@@ -293,7 +292,7 @@ MessageBus::setupRouting(const RoutingSpec &spec)
rtm[cfg.getProtocol()] = std::make_shared<RoutingTable>(cfg);
}
{
- LockGuard guard(_lock);
+ std::lock_guard guard(_lock);
std::swap(_routingTables, rtm);
}
_protocolRepository->clearPolicyCache();
@@ -360,7 +359,7 @@ MessageBus::deliverMessage(Message::UP msg, const string &session)
{
IMessageHandler *msgHandler = nullptr;
{
- LockGuard guard(_lock);
+ std::lock_guard guard(_lock);
std::map<string, IMessageHandler*>::iterator it = _sessions.find(session);
if (it != _sessions.end()) {
msgHandler = it->second;
diff --git a/messagebus/src/vespa/messagebus/messagebus.h b/messagebus/src/vespa/messagebus/messagebus.h
index c0682967db9..b12054f7006 100644
--- a/messagebus/src/vespa/messagebus/messagebus.h
+++ b/messagebus/src/vespa/messagebus/messagebus.h
@@ -10,7 +10,6 @@
#include "sourcesession.h"
#include <vespa/messagebus/network/inetworkowner.h>
#include <vespa/messagebus/routing/routingspec.h>
-#include <vespa/vespalib/util/sync.h>
#include <map>
#include <string>
#include <atomic>
@@ -38,7 +37,7 @@ class MessageBus : public IMessageHandler,
private:
using RoutingTableSP = std::shared_ptr<RoutingTable>;
INetwork &_network;
- vespalib::Lock _lock;
+ std::mutex _lock;
std::map<string, RoutingTableSP> _routingTables;
std::map<string, IMessageHandler*> _sessions;
std::unique_ptr<ProtocolRepository> _protocolRepository;
diff --git a/messagebus/src/vespa/messagebus/network/rpcnetwork.cpp b/messagebus/src/vespa/messagebus/network/rpcnetwork.cpp
index de3be2ffa01..eb94ab5ff5c 100644
--- a/messagebus/src/vespa/messagebus/network/rpcnetwork.cpp
+++ b/messagebus/src/vespa/messagebus/network/rpcnetwork.cpp
@@ -96,7 +96,7 @@ RPCNetwork::SendContext::handleVersion(const vespalib::Version *version)
{
bool shouldSend = false;
{
- vespalib::LockGuard guard(_lock);
+ std::lock_guard guard(_lock);
if (version == nullptr) {
_hasError = true;
} else if (*version < _version) {
diff --git a/messagebus/src/vespa/messagebus/network/rpcnetwork.h b/messagebus/src/vespa/messagebus/network/rpcnetwork.h
index a8eb514387c..2780c3e8770 100644
--- a/messagebus/src/vespa/messagebus/network/rpcnetwork.h
+++ b/messagebus/src/vespa/messagebus/network/rpcnetwork.h
@@ -37,7 +37,7 @@ class RPCNetwork : public INetwork,
private:
using CompressionConfig = vespalib::compression::CompressionConfig;
struct SendContext : public RPCTarget::IVersionHandler {
- vespalib::Lock _lock;
+ std::mutex _lock;
RPCNetwork &_net;
const Message &_msg;
uint32_t _traceLevel;
@@ -128,7 +128,7 @@ public:
*
* @param params A complete set of parameters.
*/
- RPCNetwork(const RPCNetworkParams &params);
+ explicit RPCNetwork(const RPCNetworkParams &params);
/**
* Destruct
diff --git a/messagebus/src/vespa/messagebus/protocolrepository.cpp b/messagebus/src/vespa/messagebus/protocolrepository.cpp
index 10ea4ecb25d..f23ef0e2ff7 100644
--- a/messagebus/src/vespa/messagebus/protocolrepository.cpp
+++ b/messagebus/src/vespa/messagebus/protocolrepository.cpp
@@ -13,7 +13,7 @@ ProtocolRepository::~ProtocolRepository() = default;
void
ProtocolRepository::clearPolicyCache()
{
- vespalib::LockGuard guard(_lock);
+ std::lock_guard guard(_lock);
_routingPolicyCache.clear();
}
@@ -67,7 +67,7 @@ ProtocolRepository::getRoutingPolicy(const string &protocolName,
{
string cacheKey = protocolName;
cacheKey.append('.').append(policyName).append(".").append(policyParam);
- vespalib::LockGuard guard(_lock);
+ std::lock_guard guard(_lock);
RoutingPolicyCache::iterator cit = _routingPolicyCache.find(cacheKey);
if (cit != _routingPolicyCache.end()) {
return cit->second;
diff --git a/messagebus/src/vespa/messagebus/protocolrepository.h b/messagebus/src/vespa/messagebus/protocolrepository.h
index b310ba3586a..28163149e2e 100644
--- a/messagebus/src/vespa/messagebus/protocolrepository.h
+++ b/messagebus/src/vespa/messagebus/protocolrepository.h
@@ -2,9 +2,9 @@
#pragma once
#include "iprotocol.h"
-#include <vespa/vespalib/util/sync.h>
#include <map>
#include <atomic>
+#include <mutex>
namespace mbus {
@@ -19,7 +19,7 @@ private:
using ProtocolMap = std::map<string, IProtocol::SP>;
using RoutingPolicyCache = std::map<string, IRoutingPolicy::SP>;
- vespalib::Lock _lock; // Only guards the cache,
+ std::mutex _lock; // Only guards the cache,
// not the protocols as they are set up during messagebus construction.
static constexpr size_t MAX_PROTOCOLS = 16;
std::pair<string, std::atomic<IProtocol *>> _protocols[MAX_PROTOCOLS];
diff --git a/messagebus/src/vespa/messagebus/sequencer.cpp b/messagebus/src/vespa/messagebus/sequencer.cpp
index e19dfa0ee61..6270284b9e2 100644
--- a/messagebus/src/vespa/messagebus/sequencer.cpp
+++ b/messagebus/src/vespa/messagebus/sequencer.cpp
@@ -38,7 +38,7 @@ Sequencer::filter(Message::UP msg)
uint64_t seqId = msg->getSequenceId();
msg->setContext(Context(seqId));
{
- vespalib::LockGuard guard(_lock);
+ std::lock_guard guard(_lock);
QueueMap::iterator it = _seqMap.find(seqId);
if (it != _seqMap.end()) {
if (it->second == nullptr) {
@@ -86,7 +86,7 @@ Sequencer::handleReply(Reply::UP reply)
make_string("Sequencer received reply with sequence id '%" PRIu64 "'.", seq));
Message::UP msg;
{
- vespalib::LockGuard guard(_lock);
+ std::lock_guard guard(_lock);
QueueMap::iterator it = _seqMap.find(seq);
MessageQueue *que = it->second;
assert(it != _seqMap.end());
@@ -100,7 +100,7 @@ Sequencer::handleReply(Reply::UP reply)
que->pop();
}
}
- if (msg.get() != nullptr) {
+ if (msg) {
sequencedSend(std::move(msg));
}
IReplyHandler &handler = reply->getCallStack().pop(*reply);
diff --git a/messagebus/src/vespa/messagebus/sequencer.h b/messagebus/src/vespa/messagebus/sequencer.h
index 7aae32fc744..54ac4ce5007 100644
--- a/messagebus/src/vespa/messagebus/sequencer.h
+++ b/messagebus/src/vespa/messagebus/sequencer.h
@@ -2,13 +2,13 @@
#pragma once
-#include <map>
-#include <vespa/vespalib/util/sync.h>
#include "imessagehandler.h"
#include "ireplyhandler.h"
#include "message.h"
#include "reply.h"
#include "queue.h"
+#include <mutex>
+#include <map>
namespace mbus {
@@ -21,7 +21,7 @@ class Sequencer : public IMessageHandler,
public IReplyHandler
{
private:
- vespalib::Lock _lock;
+ std::mutex _lock;
IMessageHandler &_sender;
typedef Queue<Message*> MessageQueue;
diff --git a/messagebus_test/src/tests/speed/cpp-client.cpp b/messagebus_test/src/tests/speed/cpp-client.cpp
index b5829c76c08..2c20b35c597 100644
--- a/messagebus_test/src/tests/speed/cpp-client.cpp
+++ b/messagebus_test/src/tests/speed/cpp-client.cpp
@@ -17,7 +17,7 @@ using namespace std::chrono_literals;
class Client : public IReplyHandler
{
private:
- vespalib::Lock _lock;
+ std::mutex _lock;
uint32_t _okCnt;
uint32_t _failCnt;
SourceSession::UP _session;
@@ -58,7 +58,7 @@ Client::send(uint64_t seq) {
void
Client::sample(uint32_t &okCnt, uint32_t &failCnt) {
- vespalib::LockGuard guard(_lock);
+ std::lock_guard guard(_lock);
okCnt = _okCnt;
failCnt = _failCnt;
}
@@ -69,7 +69,7 @@ Client::handleReply(Reply::UP reply) {
&& (reply->getType() == SimpleProtocol::REPLY)
&& (static_cast<SimpleReply&>(*reply).getValue() == "OK"))
{
- vespalib::LockGuard guard(_lock);
+ std::lock_guard guard(_lock);
++_okCnt;
} else {
fprintf(stderr, "BAD REPLY\n");
@@ -78,7 +78,7 @@ Client::handleReply(Reply::UP reply) {
reply->getError(i).getCode(),
reply->getError(i).getMessage().c_str());
}
- vespalib::LockGuard guard(_lock);
+ std::lock_guard guard(_lock);
++_failCnt;
}
send();
diff --git a/searchlib/src/vespa/searchlib/fef/tablemanager.cpp b/searchlib/src/vespa/searchlib/fef/tablemanager.cpp
index 9503e34cbaa..1aa7d4a14e9 100644
--- a/searchlib/src/vespa/searchlib/fef/tablemanager.cpp
+++ b/searchlib/src/vespa/searchlib/fef/tablemanager.cpp
@@ -2,36 +2,29 @@
#include "tablemanager.h"
-namespace search {
-namespace fef {
+namespace search::fef {
-TableManager::TableManager() :
- _factories(),
- _cache(),
- _lock()
-{
-}
+TableManager::TableManager() = default;
-TableManager::~TableManager() {}
+TableManager::~TableManager() = default;
const Table *
TableManager::getTable(const vespalib::string & name) const
{
- vespalib::LockGuard guard(_lock);
+ std::lock_guard guard(_lock);
TableCache::const_iterator itr = _cache.find(name);
if (itr != _cache.end()) {
return itr->second.get();
}
for (size_t i = 0; i < _factories.size(); ++i) {
Table::SP table = _factories[i]->createTable(name);
- if (table.get() != NULL) {
+ if (table) {
_cache.insert(std::make_pair(name, table));
return table.get();
}
}
- _cache.insert(std::make_pair(name, Table::SP(NULL)));
- return NULL;
+ _cache.insert(std::make_pair(name, Table::SP()));
+ return nullptr;
}
-} // namespace fef
-} // namespace search
+}
diff --git a/searchlib/src/vespa/searchlib/fef/tablemanager.h b/searchlib/src/vespa/searchlib/fef/tablemanager.h
index 4efd8d4aeff..4b83cb7c7a0 100644
--- a/searchlib/src/vespa/searchlib/fef/tablemanager.h
+++ b/searchlib/src/vespa/searchlib/fef/tablemanager.h
@@ -4,12 +4,11 @@
#include "itablefactory.h"
#include "itablemanager.h"
-#include <vespa/vespalib/util/sync.h>
#include <map>
#include <vector>
+#include <mutex>
-namespace search {
-namespace fef {
+namespace search::fef {
/**
* This class manages a set of tables and contains an ordered list of table factories used to create tables,
@@ -24,11 +23,11 @@ private:
typedef std::map<vespalib::string, Table::SP> TableCache;
std::vector<ITableFactory::SP> _factories;
mutable TableCache _cache;
- vespalib::Lock _lock;
+ mutable std::mutex _lock;
public:
TableManager();
- ~TableManager();
+ ~TableManager() override;
/**
* Adds a table factory to this manager.
@@ -46,6 +45,4 @@ public:
const Table * getTable(const vespalib::string & name) const override;
};
-} // namespace fef
-} // namespace search
-
+}