TimeWarp.Event (TimeWarp v0.1.0)

Copy Markdown View Source

Unit of both scheduling and inter-LP messaging (spec §4.1).

An anti-message is byte-identical to its positive twin except sign: :neg. seq is load-bearing (§8): it provides a deterministic total order over simultaneous-timestamp events and is the identity key that matches an anti-message to its positive twin.

Summary

Functions

The anti-message (negative twin) of a positive event.

Total-ordering key {timestamp, seq}. Erlang term order over this tuple is the canonical processing order; ties in timestamp break on seq.

Types

color()

@type color() :: :white | :red

lp_id()

@type lp_id() :: term()

seq()

@type seq() :: {origin :: lp_id(), counter :: non_neg_integer()}

t()

@type t() :: %TimeWarp.Event{
  color: color(),
  payload: term(),
  seq: seq(),
  sign: :pos | :neg,
  source: lp_id(),
  target: lp_id(),
  timestamp: vtime()
}

vtime()

@type vtime() :: non_neg_integer()

Functions

anti(e)

@spec anti(t()) :: t()

The anti-message (negative twin) of a positive event.

key(event)

@spec key(t()) :: {vtime(), seq()}

Total-ordering key {timestamp, seq}. Erlang term order over this tuple is the canonical processing order; ties in timestamp break on seq.