Thread Safe State Container
Thread-safe wrapper for StateContainer implementations.
This wrapper adds an additional layer of synchronization to any StateContainer, ensuring thread safety even if the underlying implementation is not thread-safe. Note that ImmutableStateContainer is already thread-safe, but this wrapper can be useful for other implementations or for additional guarantees.
Parameters
The type of state being managed
Functions
Conditionally updates the state only if the current state matches the expected state.
Updates the state and returns the previous state if successful, or null if failed.
Returns the current state cast to the specified type, or null if not of that type.
Returns true if the current state is of the specified type.
Updates the state and returns the new state if successful, or null if failed.
Extension function for StateContainer to perform atomic updates.
Updates the state using the provided updater function.
Transforms the state using a suspending function while maintaining thread safety.
Validates the given state using the container's validator.