A thread-safe, concurrent mutable reference.
Provides safe concurrent access and modification of its content, but no functionality for
synchronisation, which is instead handled by Deferred. For this reason, a Ref
is always
initialised to a value.
The default implementation is nonblocking and lightweight, consisting essentially of a purely
functional wrapper over an AtomicReference
. Consequently it ''must not'' be used to store
mutable data as AtomicReference#compareAndSet
and friends are dependent upon object
reference equality.
See also cats.effect.std.AtomicCell
class from cats-effect-std
for an alternative that
ensures exclusive access and effectual updates.
If your contents are an immutable Map[K, V]
, and all your operations are per-key, consider
using cats.effect.std.MapRef
.