Package mondrian.util
Class SlotFuture<V>
- java.lang.Object
-
- mondrian.util.SlotFuture<V>
-
- All Implemented Interfaces:
java.util.concurrent.Future<V>
public class SlotFuture<V> extends java.lang.Object implements java.util.concurrent.Future<V>
Implementation ofFuture
that completes when a thread writes a value (or an exception) into a slot.
-
-
Constructor Summary
Constructors Constructor Description SlotFuture()
Creates a SlotFuture.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
cancel(boolean mayInterruptIfRunning)
void
fail(java.lang.Throwable throwable)
Writes a throwable into the slot, indicating that the task has failed.V
get()
V
get(long timeout, java.util.concurrent.TimeUnit unit)
boolean
isCancelled()
boolean
isDone()
void
put(V value)
Writes a value into the slot, indicating that the task has completed successfully.java.lang.String
toString()
-
-
-
Method Detail
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
cancel
public boolean cancel(boolean mayInterruptIfRunning)
The SlotFuture does not know which thread is computing the result and therefore the
mayInterruptIfRunning
parameter is ignored.- Specified by:
cancel
in interfacejava.util.concurrent.Future<V>
-
isCancelled
public boolean isCancelled()
- Specified by:
isCancelled
in interfacejava.util.concurrent.Future<V>
-
isDone
public boolean isDone()
- Specified by:
isDone
in interfacejava.util.concurrent.Future<V>
-
get
public V get() throws java.util.concurrent.ExecutionException, java.lang.InterruptedException
- Specified by:
get
in interfacejava.util.concurrent.Future<V>
- Throws:
java.util.concurrent.ExecutionException
java.lang.InterruptedException
-
get
public V get(long timeout, java.util.concurrent.TimeUnit unit) throws java.util.concurrent.ExecutionException, java.lang.InterruptedException, java.util.concurrent.TimeoutException
- Specified by:
get
in interfacejava.util.concurrent.Future<V>
- Throws:
java.util.concurrent.ExecutionException
java.lang.InterruptedException
java.util.concurrent.TimeoutException
-
put
public void put(V value)
Writes a value into the slot, indicating that the task has completed successfully.- Parameters:
value
- Value to yield as the result of the computation- Throws:
java.lang.IllegalArgumentException
- if put, fail or cancel has already been invoked on this future
-
fail
public void fail(java.lang.Throwable throwable)
Writes a throwable into the slot, indicating that the task has failed.- Parameters:
throwable
- Exception that aborted the computation- Throws:
java.lang.IllegalArgumentException
- if put, fail or cancel has already been invoked on this future
-
-