MVRegister

@Serializable
class MVRegister<V> : Quilted<MVRegister<V>>

A multi-value register holding the value(s) last written. A single write yields one value; concurrent writes from different replicas are all retained until a later write observes and supersedes them — surfacing the conflict rather than silently picking a winner.

Thin wrapper over Causal<DotFun<V>>: each write mints a fresh dot → value and drops every dot it has already observed; the causal merge keeps exactly the writes that are mutually concurrent.

Samples

val a = ReplicaId("A")
val b = ReplicaId("B")

// Two replicas set independently — neither has seen the other.
val fromA = MVRegister.empty<String>().set(a, "vA")
val fromB = MVRegister.empty<String>().set(b, "vB")

val merged = fromA.piece(fromB)
check(merged.values == setOf("vA", "vB"))  // concurrent writes retained

// A later write on one replica that observes the merged state resolves it.
val resolved = merged.set(a, "resolved")
check(resolved.values == setOf("resolved"))

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
val values: Set<V>

The current value(s): one normally, several if concurrent writes are unresolved, none if never written.

Functions

Link copied to clipboard
open fun causalDots(): Set<Dot>

The causal Dots this state has delivered — (author, author-seq) per op.

Link copied to clipboard
open operator override fun equals(other: Any?): Boolean
Link copied to clipboard
open override fun hashCode(): Int
Link copied to clipboard
open override fun piece(other: MVRegister<V>): MVRegister<V>

The join: the least-upper-bound of this and other.

Link copied to clipboard
fun set(replica: ReplicaId, value: V): MVRegister<V>

Write value on behalf of replica, superseding every value this register has observed.

Link copied to clipboard
open override fun toString(): String