No matching definitions.

crdt/hlc

src/crdt/hlc.tur
defstruct

Hlc

(defstruct Hlc [wall : int logical : int replica : Sym])

a hybrid logical clock stamp.

Since: crdt-spice-plan C3

defn

hlc-max-drift

(hlc-max-drift :)

how far ahead of local wall time a remote stamp may be.

The bound, in the same unit the caller uses for wall time.

(hlc-max-drift)   ; => 60000

Since: crdt-spice-plan C3

defn

hlc-zero

(hlc-zero [r : Sym] :)

a fresh clock for a replica.

rthe replica

A stamp at wall 0, logical 0.

(hlc-zero (quote alice))

Since: crdt-spice-plan C3

defn

hlc-wall

(hlc-wall [^borrow h : Hlc] :)

the wall component.

hthe stamp

Its wall time.

(hlc-wall h)   ; => 1000

Since: crdt-spice-plan C3

defn

hlc-logical

(hlc-logical [^borrow h : Hlc] :)

the logical counter.

hthe stamp

Its logical component.

(hlc-logical h)   ; => 2

Since: crdt-spice-plan C3

defn

hlc-replica

(hlc-replica [^borrow h : Hlc] :)

the replica that issued the stamp.

hthe stamp

Its replica.

(hlc-replica h)   ; => alice

Since: crdt-spice-plan C3

defn

hlc-tick

(hlc-tick [^borrow h : Hlc now : int] :)

stamp a local event.

hthe replica's current clock
nowcurrent wall time

A stamp strictly after h.

(hlc-tick (hlc-zero (quote alice)) 1000)

Since: crdt-spice-plan C3

defn

hlc-recv

(hlc-recv [^borrow h : Hlc ^borrow m : Hlc now : int] :)

advance the local clock on receiving a remote stamp.

hthe replica's current clock
mthe remote stamp
nowcurrent wall time

A stamp at least as large as both h and m.

(hlc-recv mine theirs 1000)

Since: crdt-spice-plan C3

defn

hlc-after?

(hlc-after? [^borrow a : Hlc ^borrow b : Hlc] :)

is a strictly later than b in the total order?

afirst stamp
bsecond stamp

true when a > b by (wall, logical, replica).

(hlc-after? later earlier)   ; => true

Since: crdt-spice-plan C3

defn

hlc-later

(hlc-later [^borrow a : Hlc ^borrow b : Hlc] :)

the later of two stamps.

afirst stamp
bsecond stamp

Whichever is later in the total order.

(hlc-later mine theirs)

Since: crdt-spice-plan C3