github.com/kaisenlinux/docker.io@v0.0.0-20230510090727-ea55db55fac7/swarmkit/design/tla/EventCounter.tla (about)

     1  ---------------------------- MODULE EventCounter ----------------------------
     2  
     3  EXTENDS Integers
     4  
     5  \* The number of ``events'' that have occurred (always 0 if we're not keeping track).
     6  VARIABLE nEvents
     7  
     8  \* The maximum number of events to allow, or ``-1'' for unlimited.
     9  maxEvents == -1
    10  
    11  InitEvents ==
    12    nEvents = 0       \* Start with the counter at zero
    13  
    14  (* If we're counting events, increment the event counter.
    15     We don't increment the counter when we don't have a maximum because that
    16     would make the model infinite.
    17     Actions tagged with CountEvent cannot happen once nEvents = maxEvents. *)
    18  CountEvent ==
    19    IF maxEvents = -1 THEN
    20      UNCHANGED nEvents
    21    ELSE
    22      /\ nEvents < maxEvents
    23      /\ nEvents' = nEvents + 1
    24  
    25  =============================================================================