Package org.apache.cassandra.utils
Class RecomputingSupplier<T>
- java.lang.Object
-
- org.apache.cassandra.utils.RecomputingSupplier<T>
-
public class RecomputingSupplier<T> extends java.lang.Object
Supplier that caches the last computed value until it is reset, forcing every caller ofget(long, TimeUnit)
to wait until this value is computed if it was not computed yet. Callingrecompute()
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()
-
-
-
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 classjava.lang.Object
-
-