view 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
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;
}