diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2021-01-14 21:13:18 +0000 |
---|---|---|
committer | Henning Baldersheim <balder@yahoo-inc.com> | 2021-01-14 21:35:58 +0000 |
commit | 04465fd7fffc974cfdb767f966e92483cac381fb (patch) | |
tree | 3f902f2cc53f17d32b70ff1cff16860fd24d7a45 /searchlib | |
parent | cdb9ece95aeae9861ec5aad31c168575919ec346 (diff) |
Move idestructorcallback.h to vespalib module and search::IDestructorCallback to vespalib::IdestructorCallback.
Diffstat (limited to 'searchlib')
11 files changed, 18 insertions, 43 deletions
diff --git a/searchlib/src/tests/diskindex/fusion/fusion_test.cpp b/searchlib/src/tests/diskindex/fusion/fusion_test.cpp index 4c62140b731..ac7bfc63a15 100644 --- a/searchlib/src/tests/diskindex/fusion/fusion_test.cpp +++ b/searchlib/src/tests/diskindex/fusion/fusion_test.cpp @@ -73,7 +73,7 @@ namespace { void myPushDocument(DocumentInverter &inv) { - inv.pushDocuments(std::shared_ptr<IDestructorCallback>()); + inv.pushDocuments(std::shared_ptr<vespalib::IDestructorCallback>()); } } diff --git a/searchlib/src/tests/memoryindex/field_index/field_index_test.cpp b/searchlib/src/tests/memoryindex/field_index/field_index_test.cpp index d7b515c29e0..0deb9893dae 100644 --- a/searchlib/src/tests/memoryindex/field_index/field_index_test.cpp +++ b/searchlib/src/tests/memoryindex/field_index/field_index_test.cpp @@ -416,7 +416,7 @@ myremove(uint32_t docId, DocumentInverter &inv, { inv.removeDocument(docId); invertThreads.sync(); - inv.pushDocuments(std::shared_ptr<IDestructorCallback>()); + inv.pushDocuments(std::shared_ptr<vespalib::IDestructorCallback>()); } class MyDrainRemoves : IFieldIndexRemoveListener { @@ -442,7 +442,7 @@ public: void myPushDocument(DocumentInverter &inv) { - inv.pushDocuments(std::shared_ptr<IDestructorCallback>()); + inv.pushDocuments(std::shared_ptr<vespalib::IDestructorCallback>()); } const FeatureStore * diff --git a/searchlib/src/tests/transactionlog/chunks_test.cpp b/searchlib/src/tests/transactionlog/chunks_test.cpp index a3cf9f8bd92..aeee8a7a374 100644 --- a/searchlib/src/tests/transactionlog/chunks_test.cpp +++ b/searchlib/src/tests/transactionlog/chunks_test.cpp @@ -77,7 +77,7 @@ TEST("test empty commitchunk") { EXPECT_EQUAL(0u, cc.getNumCallBacks()); } -struct Counter : public search::IDestructorCallback { +struct Counter : public vespalib::IDestructorCallback { std::atomic<uint32_t> & _counter; Counter(std::atomic<uint32_t> & counter) noexcept : _counter(counter) { _counter++; } ~Counter() override { _counter--; } diff --git a/searchlib/src/vespa/searchlib/common/gatecallback.h b/searchlib/src/vespa/searchlib/common/gatecallback.h index 1f965ecc1d3..eaaa8c4fab9 100644 --- a/searchlib/src/vespa/searchlib/common/gatecallback.h +++ b/searchlib/src/vespa/searchlib/common/gatecallback.h @@ -1,13 +1,13 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #pragma once -#include "idestructorcallback.h" +#include "vespa/vespalib/util/idestructorcallback.h" namespace vespalib { class Gate; } namespace search { -class GateCallback : public IDestructorCallback { +class GateCallback : public vespalib::IDestructorCallback { public: GateCallback(vespalib::Gate & gate) noexcept : _gate(gate) {} ~GateCallback() override; @@ -15,14 +15,14 @@ private: vespalib::Gate & _gate; }; -class IgnoreCallback : public IDestructorCallback { +class IgnoreCallback : public vespalib::IDestructorCallback { public: IgnoreCallback() noexcept { } ~IgnoreCallback() override = default; }; template <typename T> -struct KeepAlive : public search::IDestructorCallback { +struct KeepAlive : public vespalib::IDestructorCallback { explicit KeepAlive(T toKeep) noexcept : _toKeep(std::move(toKeep)) { } ~KeepAlive() override = default; T _toKeep; diff --git a/searchlib/src/vespa/searchlib/common/idestructorcallback.h b/searchlib/src/vespa/searchlib/common/idestructorcallback.h deleted file mode 100644 index 77adba7a4cc..00000000000 --- a/searchlib/src/vespa/searchlib/common/idestructorcallback.h +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#pragma once - -#include <memory> - -namespace search { - -/** - * Interface for class that performs a callback when instance is - * destroyed. Typically a shared pointer to an instance is passed - * around to multiple worker threads that performs portions of a - * larger task before dropping the shared pointer, triggering the - * callback when all worker threads have completed. - */ -class IDestructorCallback -{ -public: - using SP = std::shared_ptr<IDestructorCallback>; - virtual ~IDestructorCallback() = default; -}; - -} // namespace search diff --git a/searchlib/src/vespa/searchlib/common/scheduletaskcallback.h b/searchlib/src/vespa/searchlib/common/scheduletaskcallback.h index 00f0d4b29f5..6ea841097a2 100644 --- a/searchlib/src/vespa/searchlib/common/scheduletaskcallback.h +++ b/searchlib/src/vespa/searchlib/common/scheduletaskcallback.h @@ -1,7 +1,7 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #pragma once -#include "idestructorcallback.h" +#include "vespa/vespalib/util/idestructorcallback.h" #include <vespa/vespalib/util/executor.h> namespace search { @@ -13,7 +13,7 @@ namespace search { * shared pointer, triggering the callback when all worker threads * have completed. */ -class ScheduleTaskCallback : public IDestructorCallback +class ScheduleTaskCallback : public vespalib::IDestructorCallback { vespalib::Executor &_executor; vespalib::Executor::Task::UP _task; diff --git a/searchlib/src/vespa/searchlib/memoryindex/document_inverter.cpp b/searchlib/src/vespa/searchlib/memoryindex/document_inverter.cpp index c8b23b2256f..03a8759c1db 100644 --- a/searchlib/src/vespa/searchlib/memoryindex/document_inverter.cpp +++ b/searchlib/src/vespa/searchlib/memoryindex/document_inverter.cpp @@ -176,7 +176,7 @@ DocumentInverter::removeDocument(uint32_t docId) } void -DocumentInverter::pushDocuments(const std::shared_ptr<IDestructorCallback> &onWriteDone) +DocumentInverter::pushDocuments(const std::shared_ptr<vespalib::IDestructorCallback> &onWriteDone) { uint32_t fieldId = 0; for (auto &inverter : _inverters) { diff --git a/searchlib/src/vespa/searchlib/memoryindex/document_inverter.h b/searchlib/src/vespa/searchlib/memoryindex/document_inverter.h index 57f51e7fdb0..cab833704e6 100644 --- a/searchlib/src/vespa/searchlib/memoryindex/document_inverter.h +++ b/searchlib/src/vespa/searchlib/memoryindex/document_inverter.h @@ -13,11 +13,8 @@ namespace document { class FieldValue; } -namespace search { - class IDestructorCallback; -} - namespace vespalib { + class IDestructorCallback; class ISequencedTaskExecutor; } @@ -87,7 +84,7 @@ public: * NOTE: The caller of this function should sync the 'invert threads' executor first, * to ensure that inverting is completed before pushing starts. */ - void pushDocuments(const std::shared_ptr<IDestructorCallback> &onWriteDone); + void pushDocuments(const std::shared_ptr<vespalib::IDestructorCallback> &onWriteDone); /** * Invert (add) the given document. diff --git a/searchlib/src/vespa/searchlib/memoryindex/memory_index.cpp b/searchlib/src/vespa/searchlib/memoryindex/memory_index.cpp index 789b7fcf452..6fad4237187 100644 --- a/searchlib/src/vespa/searchlib/memoryindex/memory_index.cpp +++ b/searchlib/src/vespa/searchlib/memoryindex/memory_index.cpp @@ -107,7 +107,7 @@ MemoryIndex::removeDocument(uint32_t docId) } void -MemoryIndex::commit(const std::shared_ptr<IDestructorCallback> &onWriteDone) +MemoryIndex::commit(const std::shared_ptr<vespalib::IDestructorCallback> &onWriteDone) { _invertThreads.sync(); // drain inverting into this inverter _pushThreads.sync(); // drain use of other inverter diff --git a/searchlib/src/vespa/searchlib/memoryindex/memory_index.h b/searchlib/src/vespa/searchlib/memoryindex/memory_index.h index 56eb4ad7a66..90d1cd7bb37 100644 --- a/searchlib/src/vespa/searchlib/memoryindex/memory_index.h +++ b/searchlib/src/vespa/searchlib/memoryindex/memory_index.h @@ -3,7 +3,7 @@ #pragma once #include <vespa/searchcommon/common/schema.h> -#include <vespa/searchlib/common/idestructorcallback.h> +#include <vespa/vespalib/util/idestructorcallback.h> #include <vespa/searchlib/index/field_length_info.h> #include <vespa/searchlib/queryeval/searchable.h> #include <vespa/vespalib/stllike/hash_set.h> @@ -125,7 +125,7 @@ public: * * Callers can call pushThreads.sync() to wait for push completion. */ - void commit(const std::shared_ptr<IDestructorCallback> &onWriteDone); + void commit(const std::shared_ptr<vespalib::IDestructorCallback> &onWriteDone); /** * Freeze this index. diff --git a/searchlib/src/vespa/searchlib/transactionlog/common.h b/searchlib/src/vespa/searchlib/transactionlog/common.h index e7462b38e53..7f2cb14da56 100644 --- a/searchlib/src/vespa/searchlib/transactionlog/common.h +++ b/searchlib/src/vespa/searchlib/transactionlog/common.h @@ -2,7 +2,7 @@ #pragma once #include <vespa/searchlib/common/serialnum.h> -#include <vespa/searchlib/common/idestructorcallback.h> +#include <vespa/vespalib/util/idestructorcallback.h> #include <vespa/vespalib/objects/nbostream.h> #include <vespa/vespalib/util/buffer.h> #include <vespa/vespalib/util/time.h> @@ -88,7 +88,7 @@ int makeDirectory(const char * dir); class Writer { public: - using DoneCallback = std::shared_ptr<IDestructorCallback>; + using DoneCallback = std::shared_ptr<vespalib::IDestructorCallback>; using DoneCallbacksList = std::vector<DoneCallback>; using CommitPayload = std::shared_ptr<DoneCallbacksList>; class CommitResult { |