Implement clears in addMutations

This commit is contained in:
2024-05-07 16:13:18 -07:00
parent 2c6ec61f82
commit 8f7fccee76
2 changed files with 151 additions and 21 deletions

View File

@@ -31,7 +31,7 @@ namespace weaselab {
*
* Thread safety:
* - It's safe to operate on two different VersionedMaps in two different
* threads concurrently
* threads concurrently.
* - It's safe to have multiple threads operating on the same VersionedMap
* concurrently if all threads only call const methods.
* - Methods that make stronger guarantees about the safety of calling
@@ -51,7 +51,7 @@ struct VersionedMap {
Clear,
};
/** bytes ordered bitwise-lexicographically. */
/** Bytes ordered bitwise-lexicographically. */
struct Key {
const uint8_t *p;
int len;
@@ -86,12 +86,15 @@ struct VersionedMap {
/** The version of the most recent call to `setOldestVersion`. */
int64_t getOldestVersion() const;
/** Iterates through a canonicalized view of all the mutations from
* `oldestVersion` to the iterator's version. There may be mutations from
/** Iterates through a partially canonicalized[1] view of all the mutations
* from `oldestVersion` to the iterator's version. There may be mutations from
* versions < `oldestVersion`, but they won't affect the result. It's
* thread-safe to operate on an iterator concurrently with any method of
* `VersionedMap`, as long as it's not invalidated by `setOldestVersion`.
* @warning must not outlive its `VersionedMap`. */
* @warning must not outlive its `VersionedMap`.
*
* [1]: Mutations are sorted and non-overlapping, but may be adjacent.
*/
struct Iterator {
Iterator() = default;