Skip to content

MVHashReg[A: Equatable[A] val, H: HashFunction[A] val]

[Source]

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


Constructors

create

[Source]

Instantiate under the given unique replica id.

new ref create(
  id: ID)
: MVHashReg[A, H] ref^

Parameters

Returns


Public Functions

is_empty

[Source]

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.

fun box is_empty()
: Bool val

Returns


result

[Source]

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.

fun box result()
: HashSet[A, H] ref

Returns


size

[Source]

Return the number of items in the set.

fun box size()
: USize val

Returns


contains

[Source]

Check whether the set contains the given value.

fun box contains(
  value': A)
: Bool val

Parameters

  • value': A

Returns


update[optional D: MVHashReg[A, H] ref]

[Source]

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]

[Source]

Remove all locally visible elements from the set. Accepts and returns a convergent delta-state.

fun ref clear[optional D: MVHashReg[A, H] ref](
  delta': D = recover MVHashReg[A, H](0) end)
: D^

Parameters

  • delta': D = recover MVHashRegA, H end

Returns

  • D^

converge

[Source]

Converge from the given MVReg into this one. Returns true if the convergence added new information to the data structure.

fun ref converge(
  that: MVHashReg[A, H] box)
: Bool val

Parameters

Returns


string

[Source]

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.

fun box string()
: String iso^

Returns


eq

[Source]

fun box eq(
  that: MVHashReg[A, H] box)
: Bool val

Parameters

Returns


ne

[Source]

fun box ne(
  that: MVHashReg[A, H] box)
: Bool val

Parameters

Returns


lt

[Source]

fun box lt(
  that: MVHashReg[A, H] box)
: Bool val

Parameters

Returns


le

[Source]

fun box le(
  that: MVHashReg[A, H] box)
: Bool val

Parameters

Returns


gt

[Source]

fun box gt(
  that: MVHashReg[A, H] box)
: Bool val

Parameters

Returns


ge

[Source]

fun box ge(
  that: MVHashReg[A, H] box)
: Bool val

Parameters

Returns


values

[Source]

fun box values()
: Iterator[A] ref^

Returns


from_tokens

[Source]

Deserialize an instance of this data structure from a stream of tokens.

fun ref from_tokens(
  that: TokensIterator ref)
: None val ?

Parameters

Returns


each_token

[Source]

Serialize the data structure, capturing each token into the given Tokens.

fun ref each_token(
  tokens: Tokens ref)
: None val

Parameters

Returns


compare

[Source]

fun box compare(
  that: MVHashReg[A, H] box)
: Compare

Parameters

Returns