MutableSnapshot

Buffers state writes and applies them atomically to a parent snapshot or global state.

Reads first observe this snapshot's buffered writes, then parent buffers, then the version pinned at creation. apply may be retried after SnapshotApplyResult.Failure, but a successful apply is terminal; do not enter or write through the snapshot afterward. The caller MUST dispose the snapshot whether it is applied or abandoned.

Mutable snapshots are not safe for concurrent entry or mutation. Conflicting destination writes are resolved independently through each state's SnapshotMutationPolicy.

Functions

Link copied to clipboard

Applies every buffered write to this snapshot's parent buffer or to global state.

Link copied to clipboard
open override fun close()

Releases this snapshot when used through AutoCloseable.

Link copied to clipboard
open override fun dispose()

Discards buffered writes and releases the pinned read version.

Link copied to clipboard
fun <R> enter(block: () -> R): R

Runs block with this snapshot as the current read context on the calling thread.