summaryrefslogtreecommitdiffstats
path: root/searchlib
diff options
context:
space:
mode:
authorTor Egge <Tor.Egge@yahooinc.com>2022-03-28 13:36:22 +0200
committerTor Egge <Tor.Egge@yahooinc.com>2022-03-28 13:36:22 +0200
commit0d2d147c5cd245f773ed01392adf0fa14f542406 (patch)
treef3cce499b705f1efba2410e4c4a77b7cbf976e01 /searchlib
parentced5ccdf29cc6785223803f1bcd24b9fd436a358 (diff)
Use atomic doc id limit in doc store.
Diffstat (limited to 'searchlib')
-rw-r--r--searchlib/src/vespa/searchlib/docstore/idatastore.h9
1 files changed, 5 insertions, 4 deletions
diff --git a/searchlib/src/vespa/searchlib/docstore/idatastore.h b/searchlib/src/vespa/searchlib/docstore/idatastore.h
index fc0eae1d15e..442614dfdae 100644
--- a/searchlib/src/vespa/searchlib/docstore/idatastore.h
+++ b/searchlib/src/vespa/searchlib/docstore/idatastore.h
@@ -7,6 +7,7 @@
#include <vespa/vespalib/stllike/string.h>
#include <vespa/vespalib/util/memoryusage.h>
#include <vespa/vespalib/util/time.h>
+#include <atomic>
#include <vector>
namespace vespalib { class DataBuffer; }
@@ -172,7 +173,7 @@ public:
* Get the number of entries (including removed IDs
* or gaps in the local ID sequence) in the data store.
*/
- uint32_t getDocIdLimit() const { return _docIdLimit; }
+ uint32_t getDocIdLimit() const { return _docIdLimit.load(std::memory_order_acquire); }
/**
* Returns the name of the base directory where the data file is stored.
@@ -181,16 +182,16 @@ public:
protected:
void setDocIdLimit(uint32_t docIdLimit) {
- _docIdLimit = docIdLimit;
+ _docIdLimit.store(docIdLimit, std::memory_order_release);
}
void updateDocIdLimit(uint32_t docIdLimit) {
- if (docIdLimit > _docIdLimit) {
+ if (docIdLimit > _docIdLimit.load(std::memory_order_relaxed)) {
setDocIdLimit(docIdLimit);
}
}
private:
- uint32_t _docIdLimit;
+ std::atomic<uint32_t> _docIdLimit;
vespalib::string _dirName;
};