ZRef[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, potentially failing with an error of type
getgets the current value of the reference and returns a value of type
B, potentially failing with an error of type
When the error and value types of the
ZRef are unified, that is, it is a
ZRef[E, E, A, A], the
ZRef also supports atomic
update operations. All operations are guaranteed to be safe for concurrent access.
ZRefprovides the functional equivalent of a mutable reference, the value inside the
ZRefshould be immutable. For performance reasons
ZRefis implemented in terms of compare and swap operations rather than synchronization. These operations are not safe for mutable values that do not support concurrent access.