MVHashReg[A: Equatable[A] val, H: HashFunction[A] val]¶
A mutable register that retains all concurrently written values. When replicas write different values without first converging, all values are kept until a subsequent update overrides them. After convergence, the register exposes the full set of concurrently written values.
This data structure delegates causality tracking to the reusable "dot kernel" abstraction. Because that abstraction provides an eventually-consistent set of replica-associated values, and this data structure uses a commutative strategy for reading out the values, the result is eventually consistent.
All mutator methods accept and return a convergent delta-state.
class ref MVHashReg[A: Equatable[A] val, H: HashFunction[A] val] is
Comparable[MVHashReg[A, H] ref] ref,
Causal[MVHashReg[A, H] ref] ref
Implements¶
- Comparable[MVHashReg[A, H] ref] ref
- Causal[MVHashReg[A, H] ref] ref
Constructors¶
create¶
Instantiate under the given unique replica id.
Parameters¶
- id: ID
Returns¶
- MVHashReg[A, H] ref^
Public Functions¶
is_empty¶
Return true if there are no values ever recorded from any replica. This is true at creation, after calling the clear method, or after a converge that results in all values being cleared.
Returns¶
- Bool val
result¶
Return the elements of the resulting logical set as a single flat set. Information about specific deletions is discarded, so that the case of a deleted element is indistinct from that of an element never inserted.
Returns¶
- HashSet[A, H] ref
size¶
Return the number of items in the set.
Returns¶
- USize val
contains¶
Check whether the set contains the given value.
Parameters¶
- value': A
Returns¶
- Bool val
update[optional D: MVHashReg[A, H] ref]¶
Set the value of the register, overriding all currently visible values. After this function, the register will have a single value locally, at least until any concurrent updates are converged, adding more values into the set. Accepts and returns a convergent delta-state.
fun ref update[optional D: MVHashReg[A, H] ref](
value': A,
delta': D = recover MVHashReg[A, H](0) end)
: D^
Parameters¶
- value': A
- delta': D = recover MVHashRegA, H end
Returns¶
- D^
clear[optional D: MVHashReg[A, H] ref]¶
Remove all locally visible elements from the set. Accepts and returns a convergent delta-state.
Parameters¶
- delta': D = recover MVHashRegA, H end
Returns¶
- D^
converge¶
Converge from the given MVReg into this one. Returns true if the convergence added new information to the data structure.
Parameters¶
- that: MVHashReg[A, H] box
Returns¶
- Bool val
string¶
Return a best effort at printing the set. If A is a Stringable, use the string representation of each value; otherwise print them as question marks.
Returns¶
- String iso^
eq¶
Parameters¶
- that: MVHashReg[A, H] box
Returns¶
- Bool val
ne¶
Parameters¶
- that: MVHashReg[A, H] box
Returns¶
- Bool val
lt¶
Parameters¶
- that: MVHashReg[A, H] box
Returns¶
- Bool val
le¶
Parameters¶
- that: MVHashReg[A, H] box
Returns¶
- Bool val
gt¶
Parameters¶
- that: MVHashReg[A, H] box
Returns¶
- Bool val
ge¶
Parameters¶
- that: MVHashReg[A, H] box
Returns¶
- Bool val
values¶
Returns¶
- Iterator[A] ref^
from_tokens¶
Deserialize an instance of this data structure from a stream of tokens.
Parameters¶
- that: TokensIterator ref
Returns¶
- None val ?
each_token¶
Serialize the data structure, capturing each token into the given Tokens.
Parameters¶
- tokens: Tokens ref
Returns¶
- None val
compare¶
Parameters¶
- that: MVHashReg[A, H] box