diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2020-10-20 19:55:40 +0000 |
---|---|---|
committer | Henning Baldersheim <balder@yahoo-inc.com> | 2020-10-20 19:55:40 +0000 |
commit | 930e77083f228b2eea278ca1ee48131250f60294 (patch) | |
tree | 0b487d603af8e1adc9bff57ed87215657b667d20 /searchcore | |
parent | b318031c33daa13b8856c677bd3d24d8cedf637b (diff) |
dedup common code.
Diffstat (limited to 'searchcore')
3 files changed, 4 insertions, 27 deletions
diff --git a/searchcore/src/vespa/searchcore/proton/server/documentdb.cpp b/searchcore/src/vespa/searchcore/proton/server/documentdb.cpp index 35966f2fcaf..b452c9335c1 100644 --- a/searchcore/src/vespa/searchcore/proton/server/documentdb.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/documentdb.cpp @@ -32,6 +32,7 @@ #include <vespa/searchlib/attribute/configconverter.h> #include <vespa/searchlib/engine/docsumreply.h> #include <vespa/searchlib/engine/searchreply.h> +#include <vespa/searchlib/common/gatecallback.h> #include <vespa/vespalib/util/closuretask.h> #include <vespa/vespalib/util/exceptions.h> @@ -101,13 +102,6 @@ findDocumentDB(const ProtonConfig::DocumentdbVector & documentDBs, const vespali return &_G_defaultProtonDocumentDBConfig; } -template <typename T> -struct KeepAlive : public search::IDestructorCallback { - explicit KeepAlive(T toKeep) noexcept : _toKeep(std::move(toKeep)) { } - ~KeepAlive() override = default; - T _toKeep; -}; - } template <typename FunctionType> @@ -454,7 +448,7 @@ DocumentDB::applyConfig(DocumentDBConfig::SP configSnapshot, SerialNum serialNum { bool elidedConfigSave = equalReplayConfig && tlsReplayDone; // Flush changes to attributes and memory index, cf. visibilityDelay - _feedView.get()->forceCommit(elidedConfigSave ? serialNum : serialNum - 1, std::make_shared<KeepAlive<FeedHandler::CommitResult>>(std::move(commit_result))); + _feedView.get()->forceCommit(elidedConfigSave ? serialNum : serialNum - 1, std::make_shared<search::KeepAlive<FeedHandler::CommitResult>>(std::move(commit_result))); _writeService.sync(); vespalib::duration visibilityDelay = configSnapshot->getMaintenanceConfigSP()->getVisibilityDelay(); hasVisibilityDelayChanged = (visibilityDelay != _visibility.getVisibilityDelay()); diff --git a/searchcore/src/vespa/searchcore/proton/server/feedhandler.cpp b/searchcore/src/vespa/searchcore/proton/server/feedhandler.cpp index 687d23a36ea..2230250d355 100644 --- a/searchcore/src/vespa/searchcore/proton/server/feedhandler.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/feedhandler.cpp @@ -120,12 +120,6 @@ private: std::unique_ptr<Executor::Task> _task; }; -template <typename T> -struct KeepAlive : public search::IDestructorCallback { - explicit KeepAlive(T toKeep) : _toKeep(std::move(toKeep)) { } - ~KeepAlive() override = default; - T _toKeep; -}; } // namespace void @@ -528,7 +522,7 @@ FeedHandler::initiateCommit() { })); auto commitResult = _tlsWriter->startCommit(onCommitDoneContext); if (_activeFeedView && ! _activeFeedView->allowEarlyAck()) { - using KeepAlivePair = KeepAlive<std::pair<CommitResult, DoneCallback>>; + using KeepAlivePair = search::KeepAlive<std::pair<CommitResult, DoneCallback>>; auto pair = std::make_pair(std::move(commitResult), std::move(onCommitDoneContext)); _activeFeedView->forceCommit(_serialNum, std::make_shared<KeepAlivePair>(std::move(pair))); } diff --git a/searchcore/src/vespa/searchcore/proton/server/lid_space_compaction_job.cpp b/searchcore/src/vespa/searchcore/proton/server/lid_space_compaction_job.cpp index 6b480f02863..a056e7b4d15 100644 --- a/searchcore/src/vespa/searchcore/proton/server/lid_space_compaction_job.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/lid_space_compaction_job.cpp @@ -76,17 +76,6 @@ LidSpaceCompactionJob::scanDocuments(const LidUsageStats &stats) return false; // more work to do (scan documents or compact lid space) } -namespace { - -template <typename T> -struct KeepAlive : public search::IDestructorCallback { - explicit KeepAlive(T toKeep) noexcept : _toKeep(std::move(toKeep)) { } - ~KeepAlive() override = default; - T _toKeep; -}; - -} - void LidSpaceCompactionJob::compactLidSpace(const LidUsageStats &stats) { @@ -95,7 +84,7 @@ LidSpaceCompactionJob::compactLidSpace(const LidUsageStats &stats) vespalib::Gate gate; auto commit_result = _opStorer.appendAndCommitOperation(op, std::make_shared<search::GateCallback>(gate)); gate.await(); - _handler.handleCompactLidSpace(op, std::make_shared<KeepAlive<decltype(commit_result)>>(std::move(commit_result))); + _handler.handleCompactLidSpace(op, std::make_shared<search::KeepAlive<decltype(commit_result)>>(std::move(commit_result))); EventLogger::lidSpaceCompactionComplete(_handler.getName(), wantedLidLimit); _shouldCompactLidSpace = false; } |