summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@oath.com>2018-07-17 11:16:32 +0200
committerHenning Baldersheim <balder@oath.com>2018-07-17 11:16:32 +0200
commit4dd5539fc9b3800a983ba35b0d7f6976a7f02848 (patch)
tree6690cef8f8bb50b9076e8f8b8dc324248ffa3f7d
parente197b746a131564eeb45370a88b337b2ac0dd191 (diff)
Use std::move and std:.make_xxxx.
-rw-r--r--searchcore/src/vespa/searchcore/proton/flushengine/flushengine.cpp6
-rw-r--r--searchcore/src/vespa/searchcore/proton/flushengine/flushengine.h8
-rw-r--r--searchcore/src/vespa/searchcore/proton/flushengine/iflushhandler.h7
-rw-r--r--searchcore/src/vespa/searchcore/proton/server/prepare_restart_handler.cpp3
-rw-r--r--searchcore/src/vespa/searchcore/proton/server/proton.cpp56
5 files changed, 30 insertions, 50 deletions
diff --git a/searchcore/src/vespa/searchcore/proton/flushengine/flushengine.cpp b/searchcore/src/vespa/searchcore/proton/flushengine/flushengine.cpp
index 474227ccd2a..f5325faf73c 100644
--- a/searchcore/src/vespa/searchcore/proton/flushengine/flushengine.cpp
+++ b/searchcore/src/vespa/searchcore/proton/flushengine/flushengine.cpp
@@ -71,7 +71,7 @@ FlushEngine::FlushEngine(std::shared_ptr<flushengine::ITlsStatsFactory> tlsStats
_idleIntervalMS(idleIntervalMS),
_taskId(0),
_threadPool(128 * 1024),
- _strategy(strategy),
+ _strategy(std::move(strategy)),
_priorityStrategy(),
_executor(numThreads, 128 * 1024),
_lock(),
@@ -81,7 +81,7 @@ FlushEngine::FlushEngine(std::shared_ptr<flushengine::ITlsStatsFactory> tlsStats
_setStrategyLock(),
_strategyLock(),
_strategyCond(),
- _tlsStatsFactory(tlsStatsFactory),
+ _tlsStatsFactory(std::move(tlsStatsFactory)),
_pendingPrune()
{ }
@@ -401,7 +401,7 @@ FlushEngine::setStrategy(IFlushStrategy::SP strategy)
return;
}
assert(!_priorityStrategy);
- _priorityStrategy = strategy;
+ _priorityStrategy = std::move(strategy);
{
std::lock_guard<std::mutex> guard(_lock);
_cond.notify_all();
diff --git a/searchcore/src/vespa/searchcore/proton/flushengine/flushengine.h b/searchcore/src/vespa/searchcore/proton/flushengine/flushengine.h
index b9ab3f802cb..c1be05ba067 100644
--- a/searchcore/src/vespa/searchcore/proton/flushengine/flushengine.h
+++ b/searchcore/src/vespa/searchcore/proton/flushengine/flushengine.h
@@ -15,7 +15,7 @@ namespace proton {
namespace flushengine { class ITlsStatsFactory; }
-class FlushEngine : public FastOS_Runnable
+class FlushEngine final : public FastOS_Runnable
{
public:
class FlushMeta {
@@ -37,9 +37,7 @@ private:
struct FlushInfo : public FlushMeta
{
FlushInfo();
- FlushInfo(uint32_t taskId,
- const IFlushTarget::SP &target,
- const vespalib::string &destination);
+ FlushInfo(uint32_t taskId, const IFlushTarget::SP &target, const vespalib::string &destination);
~FlushInfo();
IFlushTarget::SP _target;
@@ -102,7 +100,7 @@ public:
/**
* Destructor. Waits for all pending tasks to complete.
*/
- ~FlushEngine();
+ ~FlushEngine() override;
/**
* Observe and reset internal executor stats
diff --git a/searchcore/src/vespa/searchcore/proton/flushengine/iflushhandler.h b/searchcore/src/vespa/searchcore/proton/flushengine/iflushhandler.h
index 3a24330f8ec..914de9df30c 100644
--- a/searchcore/src/vespa/searchcore/proton/flushengine/iflushhandler.h
+++ b/searchcore/src/vespa/searchcore/proton/flushengine/iflushhandler.h
@@ -30,9 +30,7 @@ public:
*/
IFlushHandler(const vespalib::string &name)
: _name(name)
- {
- // empty
- }
+ { }
/**
* Virtual destructor required for inheritance.
@@ -76,8 +74,7 @@ public:
* This method is called to sync tls to stable media, up to and
* including the given serial number.
*
- * @param syncTo The last serial number that has to be persisted to stable
- * media.
+ * @param syncTo The last serial number that has to be persisted to stable media.
*/
virtual void syncTls(SerialNum syncTo) = 0;
};
diff --git a/searchcore/src/vespa/searchcore/proton/server/prepare_restart_handler.cpp b/searchcore/src/vespa/searchcore/proton/server/prepare_restart_handler.cpp
index aef49c51f7a..1c930ef1ddc 100644
--- a/searchcore/src/vespa/searchcore/proton/server/prepare_restart_handler.cpp
+++ b/searchcore/src/vespa/searchcore/proton/server/prepare_restart_handler.cpp
@@ -50,8 +50,7 @@ PrepareRestartHandler::performPrepareRestart(const ProtonConfig &protonCfg, std:
{
_running = true;
lock.unlock();
- auto strategy = std::make_shared<PrepareRestartFlushStrategy>(createPrepareRestartConfig(protonCfg));
- _flushEngine.setStrategy(strategy);
+ _flushEngine.setStrategy(std::make_shared<PrepareRestartFlushStrategy>(createPrepareRestartConfig(protonCfg)));
lock.lock();
_running = false;
_cond.notify_all();
diff --git a/searchcore/src/vespa/searchcore/proton/server/proton.cpp b/searchcore/src/vespa/searchcore/proton/server/proton.cpp
index 32dc711d5cf..6ffb82a2ad3 100644
--- a/searchcore/src/vespa/searchcore/proton/server/proton.cpp
+++ b/searchcore/src/vespa/searchcore/proton/server/proton.cpp
@@ -240,9 +240,8 @@ Proton::init(const BootstrapConfig::SP & configSnapshot)
const HwInfo & hwInfo = configSnapshot->getHwInfo();
setFS4Compression(protonConfig);
- _diskMemUsageSampler = std::make_unique<DiskMemUsageSampler>
- (protonConfig.basedir,
- diskMemUsageSamplerConfig(protonConfig, hwInfo));
+ _diskMemUsageSampler = std::make_unique<DiskMemUsageSampler>(protonConfig.basedir,
+ diskMemUsageSamplerConfig(protonConfig, hwInfo));
_tls = std::make_unique<TLS>(_configUri.createWithNewId(protonConfig.tlsconfigid), _fileHeaderContext);
_metricsEngine->addMetricsHook(_metricsHook);
@@ -253,6 +252,7 @@ Proton::init(const BootstrapConfig::SP & configSnapshot)
_distributionKey = protonConfig.distributionkey;
_summaryEngine= std::make_unique<SummaryEngine>(protonConfig.numsummarythreads);
_docsumBySlime = std::make_unique<DocsumBySlime>(*_summaryEngine);
+
IFlushStrategy::SP strategy;
const ProtonConfig::Flush & flush(protonConfig.flush);
switch (flush.strategy) {
@@ -283,17 +283,15 @@ Proton::init(const BootstrapConfig::SP & configSnapshot)
LOG(debug, "Start proton server with root at %s and cwd at %s",
protonConfig.basedir.c_str(), getcwd(tmp, sizeof(tmp)));
- _persistenceEngine.reset(new PersistenceEngine(*this,
- _diskMemUsageSampler->writeFilter(),
- protonConfig.visit.defaultserializedsize,
- protonConfig.visit.ignoremaxbytes));
-
+ _persistenceEngine = std::make_unique<PersistenceEngine>(*this, _diskMemUsageSampler->writeFilter(),
+ protonConfig.visit.defaultserializedsize,
+ protonConfig.visit.ignoremaxbytes);
vespalib::string fileConfigId;
- _warmupExecutor.reset(new vespalib::ThreadStackExecutor(4, 128*1024));
+ _warmupExecutor = std::make_unique<vespalib::ThreadStackExecutor>(4, 128*1024);
const size_t summaryThreads = deriveCompactionCompressionThreads(protonConfig, hwInfo.cpu());
- _summaryExecutor.reset(new vespalib::BlockingThreadStackExecutor(summaryThreads, 128*1024, summaryThreads*16));
+ _summaryExecutor = std::make_unique<vespalib::BlockingThreadStackExecutor>(summaryThreads, 128*1024, summaryThreads*16);
InitializeThreads initializeThreads;
if (protonConfig.initialize.threads > 0) {
initializeThreads = std::make_shared<vespalib::ThreadStackExecutor>(protonConfig.initialize.threads, 128 * 1024);
@@ -305,7 +303,7 @@ Proton::init(const BootstrapConfig::SP & configSnapshot)
_prepareRestartHandler = std::make_unique<PrepareRestartHandler>(*_flushEngine);
RPCHooks::Params rpcParams(*this, protonConfig.rpcport, _configUri.getConfigId());
rpcParams.slobrok_config = _configUri.createWithNewId(protonConfig.slobrokconfigid);
- _rpcHooks.reset(new RPCHooks(rpcParams));
+ _rpcHooks = std::make_unique<RPCHooks>(rpcParams);
waitForInitDone();
@@ -528,23 +526,11 @@ Proton::addDocumentDB(const document::DocumentType &docType,
// 1 thread per document type.
initializeThreads = std::make_shared<vespalib::ThreadStackExecutor>(1, 128 * 1024);
}
- DocumentDB::SP ret(new DocumentDB(config.basedir + "/documents",
- documentDBConfig,
- config.tlsspec,
- _queryLimiter,
- _clock,
- docTypeName,
- bucketSpace,
- config,
- *this,
- *_warmupExecutor,
- *_summaryExecutor,
- *_tls->getTransLogServer(),
- *_metricsEngine,
- _fileHeaderContext,
- std::move(config_store),
- initializeThreads,
- bootstrapConfig->getHwInfo()));
+ auto ret = std::make_shared<DocumentDB>(config.basedir + "/documents", documentDBConfig, config.tlsspec,
+ _queryLimiter, _clock, docTypeName, bucketSpace, config, *this,
+ *_warmupExecutor, *_summaryExecutor, *_tls->getTransLogServer(),
+ *_metricsEngine, _fileHeaderContext, std::move(config_store),
+ initializeThreads, bootstrapConfig->getHwInfo());
try {
ret->start();
} catch (vespalib::Exception &e) {
@@ -571,10 +557,10 @@ Proton::addDocumentDB(const document::DocumentType &docType,
// TODO: Fix race with new cluster state setting.
_persistenceEngine->putHandler(bucketSpace, docTypeName, persistenceHandler);
}
- SearchHandlerProxy::SP searchHandler(new SearchHandlerProxy(ret));
+ auto searchHandler = std::make_shared<SearchHandlerProxy>(ret);
_summaryEngine->putSearchHandler(docTypeName, searchHandler);
_matchEngine->putSearchHandler(docTypeName, searchHandler);
- FlushHandlerProxy::SP flushHandler(new FlushHandlerProxy(ret));
+ auto flushHandler = std::make_shared<FlushHandlerProxy>(ret);
_flushEngine->putFlushHandler(docTypeName, flushHandler);
_diskMemUsageSampler->notifier().addDiskMemUsageListener(ret->diskMemUsageListener());
return ret;
@@ -624,7 +610,7 @@ Proton::MonitorReply::UP
Proton::ping(MonitorRequest::UP request, MonitorClient & client)
{
(void) client;
- MonitorReply::UP reply(new MonitorReply());
+ auto reply = std::make_unique<MonitorReply>();
MonitorReply &ret = *reply;
BootstrapConfig::SP configSnapshot = getActiveConfigSnapshot();
@@ -807,8 +793,8 @@ struct DocumentDBMapExplorer : vespalib::StateExplorer {
std::shared_timed_mutex &mutex;
DocumentDBMapExplorer(const DocumentDBMap &documentDBMap_in, std::shared_timed_mutex &mutex_in)
: documentDBMap(documentDBMap_in), mutex(mutex_in) {}
- virtual void get_state(const vespalib::slime::Inserter &, bool) const override {}
- virtual std::vector<vespalib::string> get_children_names() const override {
+ void get_state(const vespalib::slime::Inserter &, bool) const override {}
+ std::vector<vespalib::string> get_children_names() const override {
std::shared_lock<std::shared_timed_mutex> guard(mutex);
std::vector<vespalib::string> names;
for (const auto &item: documentDBMap) {
@@ -816,14 +802,14 @@ struct DocumentDBMapExplorer : vespalib::StateExplorer {
}
return names;
}
- virtual std::unique_ptr<vespalib::StateExplorer> get_child(vespalib::stringref name) const override {
+ std::unique_ptr<vespalib::StateExplorer> get_child(vespalib::stringref name) const override {
typedef std::unique_ptr<StateExplorer> Explorer_UP;
std::shared_lock<std::shared_timed_mutex> guard(mutex);
auto result = documentDBMap.find(DocTypeName(vespalib::string(name)));
if (result == documentDBMap.end()) {
return Explorer_UP(nullptr);
}
- return Explorer_UP(new DocumentDBExplorer(result->second));
+ return std::make_unique<DocumentDBExplorer>(result->second);
}
};