----------------------------- MODULE Publisher ----------------------------- EXTENDS Naturals, Sequences CONSTANT Serialized VARIABLES nextSequence, assigned, pc, sent, owner vars == <> Callers == {"A", "B"} Init == /\ nextSequence = 0 /\ assigned = [c \in Callers |-> 0] /\ pc = [c \in Callers |-> "allocate"] /\ sent = <<>> /\ owner = "" Allocate(c) == /\ pc[c] = "allocate" /\ (~Serialized \/ owner = "") /\ nextSequence' = nextSequence + 1 /\ assigned' = [assigned EXCEPT ![c] = nextSequence + 1] /\ pc' = [pc EXCEPT ![c] = "send"] /\ owner' = IF Serialized THEN c ELSE owner /\ UNCHANGED sent Send(c) == /\ pc[c] = "send" /\ sent' = Append(sent, assigned[c]) /\ pc' = [pc EXCEPT ![c] = "done"] /\ owner' = IF Serialized THEN "" ELSE owner /\ UNCHANGED <> Next == \/ \E c \in Callers : Allocate(c) \/ Send(c) \/ ((\A c \in Callers : pc[c] = "done") /\ UNCHANGED vars) InOrder == \A i \in 2..Len(sent) : sent[i - 1] < sent[i] =============================================================================