summaryrefslogtreecommitdiffstats
path: root/vespalib
diff options
context:
space:
mode:
authorTor Egge <Tor.Egge@yahooinc.com>2022-03-29 12:18:22 +0200
committerTor Egge <Tor.Egge@yahooinc.com>2022-03-29 12:18:22 +0200
commit0be32803cb962fb19bc84336508a7e7029dfb3d3 (patch)
tree809ec09044dfbdf783422785076856075bc6bda6 /vespalib
parent407db61990785f6812a0db28cdbfeb4dc8bc1308 (diff)
Remove const type qualifier from member functions that should only be
called from writer in RcuVector, MultiValueMappingBase and CondensedBitVector.
Diffstat (limited to 'vespalib')
-rw-r--r--vespalib/src/vespa/vespalib/util/rcuvector.h25
1 files changed, 22 insertions, 3 deletions
diff --git a/vespalib/src/vespa/vespalib/util/rcuvector.h b/vespalib/src/vespa/vespalib/util/rcuvector.h
index fd0a7de441a..09957d14aaf 100644
--- a/vespalib/src/vespa/vespalib/util/rcuvector.h
+++ b/vespalib/src/vespa/vespalib/util/rcuvector.h
@@ -88,8 +88,10 @@ public:
* Return whether all capacity has been used. If true the next
* call to push_back() will cause an expand of the underlying
* data.
+ * isFull() should be called from writer only.
+ * Const type qualifier removed to prevent call from readers.
**/
- bool isFull() const { return _data.size() == _data.capacity(); }
+ bool isFull() { return _data.size() == _data.capacity(); }
/**
* Return the combined memory usage for this instance.
@@ -116,9 +118,26 @@ public:
}
bool empty() const { return _data.empty(); }
- size_t size() const { return _data.size(); }
- size_t capacity() const { return _data.capacity(); }
+ /*
+ * size() should be called from writer only.
+ * Const type qualifier removed to prevent call from readers.
+ */
+ size_t size() { return _data.size(); }
+ /*
+ * get_size() should be called from writer only or with proper lock held.
+ * Used in predicate attribute by reader (causing data race).
+ */
+ size_t get_size() const { return _data.size(); }
+ /*
+ * capacity() should be called from writer only.
+ * Const type qualifier removed to prevent call from readers.
+ */
+ size_t capacity() { return _data.capacity(); }
void clear() { _data.clear(); }
+ /*
+ * operator[]() should be called from writer only.
+ * Overload with const type qualifier removed to prevent call from readers.
+ */
T & operator[](size_t i) { return _data[i]; }
/*
* Readers holding a generation guard can call acquire_elem_ref(i)