Mercurial Hosting > nabble
view src/fschmidt/util/java/FutureValue.java @ 69:4bc1fc540265 default tip
update luan
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Sun, 05 Oct 2025 20:45:39 -0600 |
parents | 00520880ad02 |
children |
line wrap: on
line source
package fschmidt.util.java; import java.util.concurrent.Callable; import java.util.concurrent.ExecutionException; public abstract class FutureValue<V> { private final FastFuture<V> ft = new FastFuture<V>(new Callable<V>() { public V call() throws Exception { return compute(); } }); public V get() throws ComputationException { ft.run(); try { return ft.get(); } catch(InterruptedException e) { throw new ComputationException(e); } catch(ExecutionException e) { throw ComputationException.newInstance(e); } } protected abstract V compute() throws Exception; }