ZRef.Synchronized[RA, RB, EA, EB, A, B] is a polymorphic, purely functional description of a mutable reference.
The fundamental operations of a
settakes a value of type
Aand sets the reference to a new value, requiring an environment of type
RAand potentially failing with an error of type
getgets the current value of the reference and returns a value of type
B, requiring an environment of type
RBand potentially failing with an error of type
When the error and value types of the
ZRef.Synchronized are unified, that is, it is a
ZRef.Synchronized[E, E, A, A], the
ZRef.Synchronized also supports atomic
ZRef.Synchronizedallows performing effects within update operations, at some cost to performance. Writes will semantically block other writers, while multiple readers can read simultaneously.