From 3d4f037f782e87d13045bdb8b8d78eda49f06267 Mon Sep 17 00:00:00 2001 From: Henning Baldersheim Date: Wed, 24 May 2023 11:38:57 +0000 Subject: Holding the generation guard is sufficient --- .../vespa/searchlib/attribute/attributevector.h | 24 +++++++--------------- .../imported_attribute_vector_read_guard.cpp | 2 +- .../imported_attribute_vector_read_guard.h | 2 +- 3 files changed, 9 insertions(+), 19 deletions(-) (limited to 'searchlib') diff --git a/searchlib/src/vespa/searchlib/attribute/attributevector.h b/searchlib/src/vespa/searchlib/attribute/attributevector.h index 6bab0f278ca..e3a7fdeb2c3 100644 --- a/searchlib/src/vespa/searchlib/attribute/attributevector.h +++ b/searchlib/src/vespa/searchlib/attribute/attributevector.h @@ -440,7 +440,13 @@ private: vespalib::steady_time _nextStatUpdateTime; std::shared_ptr _memory_allocator; -////// Locking strategy interface. only available from the Guards. + /// Clean up [0, firstUsed> + virtual void reclaim_memory(generation_t oldest_used_gen); + virtual void before_inc_generation(generation_t current_gen); + virtual void onUpdateStat() = 0; + friend class AttributeTest; +public: + ////// Locking strategy interface. /** * Used to guard that a value you reference will always reference * a value. It might not be the same value, but at least it will @@ -448,22 +454,6 @@ private: * the guard is alive. */ GenerationHandler::Guard takeGenerationGuard() { return _genHandler.takeGuard(); } - - /// Clean up [0, firstUsed> - virtual void reclaim_memory(generation_t oldest_used_gen); - virtual void before_inc_generation(generation_t current_gen); - virtual void onUpdateStat() = 0; - /** - * Used to regulate access to critical resources. Apply the - * reader/writer guards. - */ - std::shared_mutex & getEnumLock() { return _enumLock; } - - friend class ComponentGuard; - friend class AttributeValueGuard; - friend class AttributeTest; - friend class AttributeManagerTest; -public: bool headerTypeOK(const vespalib::GenericHeader &header) const; bool hasMultiValue() const override final; bool hasWeightedSetType() const override final; diff --git a/searchlib/src/vespa/searchlib/attribute/imported_attribute_vector_read_guard.cpp b/searchlib/src/vespa/searchlib/attribute/imported_attribute_vector_read_guard.cpp index b50a3720ff8..0a5e2e91446 100644 --- a/searchlib/src/vespa/searchlib/attribute/imported_attribute_vector_read_guard.cpp +++ b/searchlib/src/vespa/searchlib/attribute/imported_attribute_vector_read_guard.cpp @@ -18,7 +18,7 @@ ImportedAttributeVectorReadGuard::ImportedAttributeVectorReadGuard(std::shared_p _imported_attribute(imported_attribute), _targetLids(), _target_docid_limit(0u), - _reference_attribute_guard(imported_attribute.getReferenceAttribute()), + _reference_attribute_guard(imported_attribute.getReferenceAttribute()->takeGenerationGuard()), _target_attribute_guard(imported_attribute.getTargetAttribute()->makeReadGuard(stableEnumGuard)), _reference_attribute(*imported_attribute.getReferenceAttribute()), _target_attribute(*_target_attribute_guard->attribute()) diff --git a/searchlib/src/vespa/searchlib/attribute/imported_attribute_vector_read_guard.h b/searchlib/src/vespa/searchlib/attribute/imported_attribute_vector_read_guard.h index 5889934fa23..c984725c6e4 100644 --- a/searchlib/src/vespa/searchlib/attribute/imported_attribute_vector_read_guard.h +++ b/searchlib/src/vespa/searchlib/attribute/imported_attribute_vector_read_guard.h @@ -96,7 +96,7 @@ private: const ImportedAttributeVector &_imported_attribute; TargetLids _targetLids; uint32_t _target_docid_limit; - AttributeGuard _reference_attribute_guard; + vespalib::GenerationHandler::Guard _reference_attribute_guard; std::unique_ptr _target_attribute_guard; const ReferenceAttribute &_reference_attribute; protected: -- cgit v1.2.3