Class StateMachine

  • All Implemented Interfaces:

    
    public abstract class StateMachine
    
                        

    An abstract base class for implementing a state machine.

    Manages state transitions and ensures thread-safe state updates.

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
    • Field Summary

      Fields 
      Modifier and Type Field Description
    • Constructor Summary

      Constructors 
      Constructor Description
      StateMachine(CoroutineScope coroutineScope)
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • Method Summary

      Modifier and Type Method Description
      final Unit changeState(State newState, State callerState) Changes the state of the state machine asynchronously.
      final Unit changeStateSuspending(State newState, State callerState) Changes the state of the state machine synchronously.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • StateMachine

        StateMachine(CoroutineScope coroutineScope)
    • 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.