Atomic

data class Atomic(val reentrant: Boolean = true) : StateStrategy

Enables transaction serialization for state updates, making state updates atomic and suspendable.

  • Synchronizes state updates, allowing only one client to read and/or update the state at a time. All other clients attempting to get the state will wait on a FIFO queue and suspend the parent coroutine.

  • This strategy configures state transactions for the whole store. For one-time usage of non-atomic updates, see updateStateImmediate.

  • Has a small performance impact because of coroutine context switching and mutex usage.

  • Performance impact can be minimized at the cost of lock reentrancy. Set reentrant to false to use it, but HERE BE DRAGONS if you do that, as using the state within another state transaction will cause a permanent deadlock.

Constructors

Link copied to clipboard
constructor(reentrant: Boolean = true)

Properties

Link copied to clipboard
val reentrant: Boolean = true