Class StateMachine
-
- All Implemented Interfaces:
public abstract class StateMachineAn abstract base class for implementing a state machine.
Manages state transitions and ensures thread-safe state updates.
-
-
Constructor Summary
Constructors Constructor Description StateMachine(CoroutineScope coroutineScope)
-
Method Summary
Modifier and Type Method Description final UnitchangeState(State newState, State callerState)Changes the state of the state machine asynchronously. final UnitchangeStateSuspending(State newState, State callerState)Changes the state of the state machine synchronously. -
-
Method Detail
-
changeState
final Unit changeState(State newState, State callerState)
Changes the state of the state machine asynchronously.
Transitions to newState only if the currentState matches the callerState.
- Parameters:
newState- The new state to transition to.callerState- The expected current state for the transition to be valid.
-
changeStateSuspending
final Unit changeStateSuspending(State newState, State callerState)
Changes the state of the state machine synchronously.
Transitions to newState only if the currentState matches the callerState.
- Parameters:
newState- The new state to transition to.callerState- The expected current state for the transition to be valid.
-
-
-
-