Class BaseWatchable.Gate

  • Enclosing class:
    BaseWatchable

    class BaseWatchable.Gate
    extends java.lang.Object
    A class that lets us give it a target time or number of steps, and will tell us to stop after that much time or that many steps
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private long nextGate
      the next gate, whether time or iterations
      private boolean timeBased
      whether this is a time-based (true) or step-based (false) gate
    • Constructor Summary

      Constructors 
      Constructor Description
      Gate()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean iterate()
      Notify the gate of one iteration.
      void setStopIterations​(int iterations)
      set the number of iterations until we stop
      void setStopTime​(long millisFromNow)
      set the stop time
      boolean stop()
      check whether we should stop.
      • Methods inherited from class java.lang.Object

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

      • timeBased

        private boolean timeBased
        whether this is a time-based (true) or step-based (false) gate
      • nextGate

        private long nextGate
        the next gate, whether time or iterations
    • Constructor Detail

      • Gate

        Gate()
    • Method Detail

      • setStopTime

        public void setStopTime​(long millisFromNow)
        set the stop time
      • setStopIterations

        public void setStopIterations​(int iterations)
        set the number of iterations until we stop
      • stop

        public boolean stop()
        check whether we should stop.
      • iterate

        public boolean iterate()
        Notify the gate of one iteration. Returns true if we should stop or false if not