Use atomic doc id limit in doc store.
#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;
};
