Use std::atomic<bool> to get barriers.
#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;
};
}
