Class RecomputingSupplier<T>


  • public class RecomputingSupplier<T>
    extends java.lang.Object
    Supplier that caches the last computed value until it is reset, forcing every caller of get(long, TimeUnit) to wait until this value is computed if it was not computed yet. Calling recompute() won't reset value for the already waiting consumers, but instead will schedule one recomputation as soon as current one is done.
    • Constructor Summary

      Constructors 
      Constructor Description
      RecomputingSupplier​(java.util.function.Supplier<T> supplier, java.util.concurrent.ExecutorService executor)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      T get​(long timeout, java.util.concurrent.TimeUnit timeUnit)  
      void recompute()  
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

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

      • RecomputingSupplier

        public RecomputingSupplier​(java.util.function.Supplier<T> supplier,
                                   java.util.concurrent.ExecutorService executor)
    • Method Detail

      • recompute

        public void recompute()
      • get

        public T get​(long timeout,
                     java.util.concurrent.TimeUnit timeUnit)
              throws java.lang.InterruptedException,
                     java.util.concurrent.ExecutionException,
                     java.util.concurrent.TimeoutException
        Throws:
        java.lang.InterruptedException
        java.util.concurrent.ExecutionException
        java.util.concurrent.TimeoutException
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object