X - result typepublic abstract class SyncLazyFuture<X>
extends java.lang.Object
implements java.util.concurrent.Future<X>
withRunningThread().
tested faster on android than LatchedLazyFuture, but does not support timeout
| Constructor and Description |
|---|
SyncLazyFuture() |
| Modifier and Type | Method and Description |
|---|---|
protected abstract X |
calculate() |
boolean |
cancel(boolean mayInterruptIfRunning) |
X |
get() |
X |
get(long timeout,
java.util.concurrent.TimeUnit unit) |
boolean |
isCancelled() |
boolean |
isDone() |
SyncLazyFuture<X> |
withRunningThread()
spawns a new thread if not already started or done (otherwise, calculation happens in the first get call)
|
public boolean cancel(boolean mayInterruptIfRunning)
cancel in interface java.util.concurrent.Future<X>public boolean isCancelled()
isCancelled in interface java.util.concurrent.Future<X>public boolean isDone()
isDone in interface java.util.concurrent.Future<X>public X get() throws java.lang.InterruptedException, java.util.concurrent.ExecutionException
get in interface java.util.concurrent.Future<X>java.lang.InterruptedExceptionjava.util.concurrent.ExecutionExceptionpublic X get(long timeout, java.util.concurrent.TimeUnit unit) throws java.lang.InterruptedException, java.util.concurrent.ExecutionException, java.util.concurrent.TimeoutException
get in interface java.util.concurrent.Future<X>java.lang.InterruptedExceptionjava.util.concurrent.ExecutionExceptionjava.util.concurrent.TimeoutExceptionprotected abstract X calculate() throws java.util.concurrent.ExecutionException, java.lang.InterruptedException
java.util.concurrent.ExecutionExceptionjava.lang.InterruptedExceptionpublic SyncLazyFuture<X> withRunningThread()