enter

fun <R> enter(block: () -> R): R(source)

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

The previous snapshot context is restored even when block throws. Writes made without an explicitly entered MutableSnapshot still use an automatic global transaction and do not change the values read through this pinned snapshot.

Return

the value returned by block

Parameters

block

synchronous work executed under this snapshot

Type Parameters

R

type of value returned by block

Throws

if this snapshot has already been disposed