Single-cell register model: read, write, and compare-and-swap.
Operations:
:read— invoke valuenil(no args). Completionvalueis the value the system claims to have read. Valid iff equal to the model's current state.:write— invoke value is the value to write. Completion:okmeans the model's state becomes that value. Completion:fail/:infomeans the state may or may not have changed (the checker's job to handle).:cas— invoke value is{expected, new}. Completion:okwith valuetruemeans CAS succeeded (state wasexpected, nownew). Completion:okwith valuefalsemeans CAS failed (state wasn'texpected, no change).
Initial state is nil. Treat that as "no value yet"; :read from
the initial state is only valid if it returns nil.