Class RestrictionInterrupter<T>


  • public class RestrictionInterrupter<T>
    extends java.lang.Object
    An interrupter for restriction tracker of type T.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean tryInterrupt​(@NonNull T position)
      Returns true if the restriction tracker should be interrupted in claiming new positions.
      static <T> RestrictionInterrupter<T> withSoftTimeout​(org.joda.time.Duration timeout)
      Sets a soft timeout from now for processing new positions.
      • Methods inherited from class java.lang.Object

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

      • withSoftTimeout

        public static <T> RestrictionInterrupter<T> withSoftTimeout​(org.joda.time.Duration timeout)
        Sets a soft timeout from now for processing new positions. After the timeout the tryInterrupt will start returning true indicating an early exit from processing.
      • tryInterrupt

        public boolean tryInterrupt​(@NonNull T position)
        Returns true if the restriction tracker should be interrupted in claiming new positions.
        1. If soft deadline hasn't been reached always returns false.
        2. If soft deadline has been reached but we haven't processed any positions returns false.
        3. If soft deadline has been reached but the new position is the same as the last attempted position returns false.
        4. If soft deadline has been reached and the new position differs from the last attempted position returns true.
        Returns:
        true if the position processing should continue, false if the soft deadline has been reached and we have fully processed the previous position.