Package org.mapsforge.map.layer.hills
Class LatchedLazyFuture<X>
- java.lang.Object
-
- org.mapsforge.map.layer.hills.LatchedLazyFuture<X>
-
- Type Parameters:
X
- result type
- All Implemented Interfaces:
java.util.concurrent.Future<X>
- Direct Known Subclasses:
LazyFuture
public abstract class LatchedLazyFuture<X> extends java.lang.Object implements java.util.concurrent.Future<X>
A simple calculation future for cross-thread result sharing and optional eager parallelism viawithRunningThread()
.
-
-
Constructor Summary
Constructors Constructor Description LatchedLazyFuture()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract X
calculate()
boolean
cancel(boolean mayInterruptIfRunning)
X
get()
X
get(long timeout, java.util.concurrent.TimeUnit unit)
boolean
isCancelled()
boolean
isDone()
LatchedLazyFuture<X>
withRunningThread()
spawns a new thread if not already started or done (otherwise, calculation happens in the first get call)
-
-
-
Method Detail
-
cancel
public boolean cancel(boolean mayInterruptIfRunning)
- Specified by:
cancel
in interfacejava.util.concurrent.Future<X>
-
isCancelled
public boolean isCancelled()
- Specified by:
isCancelled
in interfacejava.util.concurrent.Future<X>
-
isDone
public boolean isDone()
- Specified by:
isDone
in interfacejava.util.concurrent.Future<X>
-
get
public X get() throws java.lang.InterruptedException, java.util.concurrent.ExecutionException
- Specified by:
get
in interfacejava.util.concurrent.Future<X>
- Throws:
java.lang.InterruptedException
java.util.concurrent.ExecutionException
-
get
public X get(long timeout, java.util.concurrent.TimeUnit unit) throws java.lang.InterruptedException, java.util.concurrent.ExecutionException, java.util.concurrent.TimeoutException
- Specified by:
get
in interfacejava.util.concurrent.Future<X>
- Throws:
java.lang.InterruptedException
java.util.concurrent.ExecutionException
java.util.concurrent.TimeoutException
-
calculate
protected abstract X calculate() throws java.util.concurrent.ExecutionException, java.lang.InterruptedException
- Throws:
java.util.concurrent.ExecutionException
java.lang.InterruptedException
-
withRunningThread
public LatchedLazyFuture<X> withRunningThread()
spawns a new thread if not already started or done (otherwise, calculation happens in the first get call)- Returns:
- this for chaining
-
-