Package sudoku

Class TimerManager


  • public class TimerManager
    extends akka.actor.typed.javadsl.AbstractBehavior<TimerManager.Protocol>
    Agent that manages Timers (in parallel), responding to the Teacher.
    • Field Detail

      • _parent

        private final akka.actor.typed.ActorRef<Teacher.Protocol> _parent
        Parent - the only agent TimeManager replies to.
      • _lastTimerId

        private int _lastTimerId
        Timers counter - it also represents the latest timerId. First timerId = 1.
      • _lastIterationId

        private int _lastIterationId
      • _latelyRequestedTableIds

        private int[] _latelyRequestedTableIds
        Table Ids requested to be checked on the last message.
    • Method Detail

      • createReceive

        public akka.actor.typed.javadsl.Receive<TimerManager.Protocol> createReceive()
        Main method controlling incoming messages. Existence required by Akka.
        Specified by:
        createReceive in class akka.actor.typed.javadsl.AbstractBehavior<TimerManager.Protocol>
        Returns:
        wrapped Behavior
      • onRemindToCheckTables

        private akka.actor.typed.Behavior<TimerManager.Protocol> onRemindToCheckTables​(TimerManager.RemindToCheckTablesMsg msg)
        TimerManager when asked by the Teacher, creates an agent - Timer to measure some time. If the Teacher does not send another RemindToCheckTablesMsg until Timer ends clicking, it means that its Tables are not responding. Note that Teacher can send _tableIds == null, meaning that it last Table had finished.
        Parameters:
        msg - request from the Teacher
        Returns:
        wrapped Behavior
      • onNewIterationStarted

        private akka.actor.typed.Behavior<TimerManager.Protocol> onNewIterationStarted​(TimerManager.NewIterationStartedMsg msg)
        TimerManager when asked by the Teacher, creates an agent - Timer to measure some time. If the Teacher does not send another NewIterationStartedMsg until Timer ends clicking, it means that there is some timeout.
        Parameters:
        msg - request from the Teacher
        Returns:
        wrapped Behavior
      • onTimePassed

        private akka.actor.typed.Behavior<TimerManager.Protocol> onTimePassed​(TimerManager.TimePassedMsg msg)
        TimerManager is informed that certain time has passed. If in this very moment TimerManager did not received new reminder, it should reply with warning that Teacher's Tables are not responding. Timer, who sent this msg, is no longer needed - can be removed.
        Parameters:
        msg - ping from the Timer
        Returns:
        wrapped Behavior