Mercurial Hosting > nabble
comparison src/fschmidt/util/java/FutureValue.java @ 68:00520880ad02
add fschmidt source
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Sun, 05 Oct 2025 17:24:15 -0600 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
67:9d0fefce6985 | 68:00520880ad02 |
---|---|
1 package fschmidt.util.java; | |
2 | |
3 import java.util.concurrent.Callable; | |
4 import java.util.concurrent.ExecutionException; | |
5 | |
6 | |
7 public abstract class FutureValue<V> { | |
8 | |
9 private final FastFuture<V> ft = new FastFuture<V>(new Callable<V>() { | |
10 public V call() throws Exception { | |
11 return compute(); | |
12 } | |
13 }); | |
14 | |
15 public V get() throws ComputationException { | |
16 ft.run(); | |
17 try { | |
18 return ft.get(); | |
19 } catch(InterruptedException e) { | |
20 throw new ComputationException(e); | |
21 } catch(ExecutionException e) { | |
22 throw ComputationException.newInstance(e); | |
23 } | |
24 } | |
25 | |
26 protected abstract V compute() throws Exception; | |
27 } |