A ZRef.Synchronized[RA, RB, EA, EB, A, B]
is a polymorphic, purely
functional description of a mutable reference.
A ZRef.Synchronized[RA, RB, EA, EB, A, B]
is a polymorphic, purely
functional description of a mutable reference. The fundamental operations
of a ZRef.Synchronized
are set
and get
. set
takes a value of type
A
and sets the reference to a new value, requiring an environment of type
RA
and potentially failing with an error of type EA
. get
gets the
current value of the reference and returns a value of type B
, requiring
an environment of type RB
and potentially failing with an error of type
EB
.
When the error and value types of the ZRef.Synchronized
are unified, that
is, it is a ZRef.Synchronized[R, R, E, E, A, A]
, the ZRef.Synchronized
also supports atomic modify
and update
operations.
Unlike an ordinary ZRef
, a ZRef.Synchronized
allows performing effects
within update operations, at some cost to performance. Writes will
semantically block other writers, while multiple readers can read
simultaneously.
ZRef.Synchronized
also supports composing multiple ZRef.Synchronized
values together to form a single ZRef.Synchronized
value that can be
atomically updated using the zip
operator. In this case reads and writes
will semantically block other readers and writers.
Creates a new ZRef
with the specified value.
Creates a new managed ZRef
with the specified value