summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTor Egge <Tor.Egge@online.no>2022-11-26 16:56:33 +0100
committerTor Egge <Tor.Egge@online.no>2022-11-26 16:56:33 +0100
commit45e57f5f4a4db4c3d4f37ba80b0c8da7c2c36a32 (patch)
treebc1c15f7d0c6594250ca807bc5a0bb53db856ad8
parent46a1ed45abb3f7635069ff07d9e046406fe1062f (diff)
Use atomic variable for search::attribute::Status::_bitVectors.
-rw-r--r--searchlib/src/vespa/searchcommon/attribute/status.cpp4
-rw-r--r--searchlib/src/vespa/searchcommon/attribute/status.h8
2 files changed, 6 insertions, 6 deletions
diff --git a/searchlib/src/vespa/searchcommon/attribute/status.cpp b/searchlib/src/vespa/searchcommon/attribute/status.cpp
index a7d1f5b3d38..41a40038431 100644
--- a/searchlib/src/vespa/searchcommon/attribute/status.cpp
+++ b/searchlib/src/vespa/searchcommon/attribute/status.cpp
@@ -37,7 +37,7 @@ Status::Status(const Status& rhs)
_lastSyncToken(rhs.getLastSyncToken()),
_updates(rhs._updates),
_nonIdempotentUpdates(rhs._nonIdempotentUpdates),
- _bitVectors(rhs._bitVectors)
+ _bitVectors(load_relaxed(rhs._bitVectors))
{
}
@@ -56,7 +56,7 @@ Status::operator=(const Status& rhs)
setLastSyncToken(rhs.getLastSyncToken());
_updates = rhs._updates;
_nonIdempotentUpdates = rhs._nonIdempotentUpdates;
- _bitVectors = rhs._bitVectors;
+ store_relaxed(_bitVectors, load_relaxed(rhs._bitVectors));
return *this;
}
diff --git a/searchlib/src/vespa/searchcommon/attribute/status.h b/searchlib/src/vespa/searchcommon/attribute/status.h
index f2212d4c76a..3bf547b2a4c 100644
--- a/searchlib/src/vespa/searchcommon/attribute/status.h
+++ b/searchlib/src/vespa/searchcommon/attribute/status.h
@@ -29,7 +29,7 @@ public:
uint64_t getLastSyncToken() const { return _lastSyncToken.load(std::memory_order_relaxed); }
uint64_t getUpdateCount() const { return _updates; }
uint64_t getNonIdempotentUpdateCount() const { return _nonIdempotentUpdates; }
- uint32_t getBitVectors() const { return _bitVectors; }
+ uint32_t getBitVectors() const { return _bitVectors.load(std::memory_order_relaxed); }
void setNumDocs(uint64_t v) { _numDocs.store(v, std::memory_order_relaxed); }
void incNumDocs() { _numDocs.store(_numDocs.load(std::memory_order_relaxed) + 1u,
@@ -37,8 +37,8 @@ public:
void setLastSyncToken(uint64_t v) { _lastSyncToken.store(v, std::memory_order_relaxed); }
void incUpdates(uint64_t v=1) { _updates += v; }
void incNonIdempotentUpdates(uint64_t v = 1) { _nonIdempotentUpdates += v; }
- void incBitVectors() { ++_bitVectors; }
- void decBitVectors() { --_bitVectors; }
+ void incBitVectors() { _bitVectors.store(getBitVectors() + 1, std::memory_order_relaxed); }
+ void decBitVectors() { _bitVectors.store(getBitVectors() - 1, std::memory_order_relaxed); }
static vespalib::string
createName(vespalib::stringref index, vespalib::stringref attr);
@@ -55,7 +55,7 @@ private:
std::atomic<uint64_t> _lastSyncToken;
uint64_t _updates;
uint64_t _nonIdempotentUpdates;
- uint32_t _bitVectors;
+ std::atomic<uint32_t> _bitVectors;
};
}