diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2021-03-04 21:43:05 +0000 |
---|---|---|
committer | Henning Baldersheim <balder@yahoo-inc.com> | 2021-03-04 21:43:05 +0000 |
commit | e9f3757b93d24584b6cadee146fdfa58a1e9b626 (patch) | |
tree | 111a6eb2ff24edef5c9b212902886eda30864817 /searchlib | |
parent | 1f52c67427b18d8a5ef16e78085be2b5f3253ec5 (diff) |
Use std::atomic<bool> to get barriers.
Diffstat (limited to 'searchlib')
-rw-r--r-- | searchlib/src/vespa/searchlib/query/query_term_ucs4.h | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/searchlib/src/vespa/searchlib/query/query_term_ucs4.h b/searchlib/src/vespa/searchlib/query/query_term_ucs4.h index d5e92acb378..c6e5c885155 100644 --- a/searchlib/src/vespa/searchlib/query/query_term_ucs4.h +++ b/searchlib/src/vespa/searchlib/query/query_term_ucs4.h @@ -2,10 +2,8 @@ #pragma once #include "query_term_simple.h" -#include <vespa/vespalib/util/memory.h> -#include <vespa/vespalib/objects/objectvisitor.h> #include <vespa/fastlib/text/unicodeutil.h> -#include <vector> +#include <atomic> namespace search { @@ -17,8 +15,8 @@ public: typedef std::unique_ptr<QueryTermUCS4> UP; QueryTermUCS4(const QueryTermUCS4 &) = delete; QueryTermUCS4 & operator = (const QueryTermUCS4 &) = delete; - QueryTermUCS4(QueryTermUCS4 &&) = default; - QueryTermUCS4 & operator = (QueryTermUCS4 &&) = default; + QueryTermUCS4(QueryTermUCS4 &&) = delete; + QueryTermUCS4 & operator = (QueryTermUCS4 &&) = delete; QueryTermUCS4(); QueryTermUCS4(const string & term_, Type type); ~QueryTermUCS4(); @@ -26,7 +24,7 @@ public: uint32_t term(const char * & t) const { t = getTerm(); return _cachedTermLen; } void visitMembers(vespalib::ObjectVisitor &visitor) const override; uint32_t term(const ucs4_t * & t) { - if (!_filled) { + if (!_filled.load(std::memory_order_relaxed)) { fillUCS4(); } t = (_termUCS4) ? _termUCS4.get() : &ZERO_TERM; @@ -37,7 +35,7 @@ private: static ucs4_t ZERO_TERM; std::unique_ptr<ucs4_t[]> _termUCS4; uint32_t _cachedTermLen; - bool _filled; + std::atomic<bool> _filled; }; } |