V
- public static class ExecutionService.DistributedFuture<V> extends java.lang.Object implements java.util.concurrent.RunnableFuture<V>, ExecutorNotification, NotifyingFuture<V>
Modifier and Type | Class and Description |
---|---|
protected static class |
ExecutionService.DistributedFuture.Sync<V>
Synchronization control for FutureTask.
|
Modifier and Type | Field and Description |
---|---|
protected ExecutionService.DistributedFuture.Sync<V> |
sync
Synchronization control for FutureTask
|
Constructor and Description |
---|
DistributedFuture(Channel channel,
java.util.concurrent.locks.Lock unfinishedLock,
java.util.concurrent.locks.Condition condition,
java.util.Set<java.util.concurrent.Future<?>> futuresToFinish,
java.util.concurrent.Callable<V> callable)
Creates a FutureTask that will upon running, execute the
given Callable.
|
DistributedFuture(Channel channel,
java.util.concurrent.locks.Lock unfinishedLock,
java.util.concurrent.locks.Condition condition,
java.util.Set<java.util.concurrent.Future<?>> futuresToFinish,
java.lang.Runnable runnable,
V result)
Creates a FutureTask that will upon running, execute the
given Runnable, and arrange that get will return the
given result on successful completion.
|
Modifier and Type | Method and Description |
---|---|
boolean |
cancel(boolean mayInterruptIfRunning) |
protected void |
done()
Protected method invoked when this task transitions to state
isDone (whether normally or via cancellation).
|
V |
get() |
V |
get(long timeout,
java.util.concurrent.TimeUnit unit) |
java.util.concurrent.Callable<V> |
getCallable() |
void |
interrupted(java.lang.Runnable runnable) |
boolean |
isCancelled() |
boolean |
isDone() |
void |
resultReturned(java.lang.Object obj) |
void |
run()
Sets this Future to the result of its computation
unless it has been cancelled.
|
protected void |
set(V v)
Sets the result of this Future to the given value unless
this future has already been set or has been cancelled.
|
protected void |
setException(java.lang.Throwable t)
Causes this future to report an ExecutionException
with the given throwable as its cause, unless this Future has
already been set or has been cancelled.
|
NotifyingFuture<V> |
setListener(FutureListener<V> listener)
Attaches a listener and returns the same future instance, to allow for 'building' futures.
|
void |
throwableEncountered(java.lang.Throwable t) |
java.lang.String |
toString() |
protected final ExecutionService.DistributedFuture.Sync<V> sync
public DistributedFuture(Channel channel, java.util.concurrent.locks.Lock unfinishedLock, java.util.concurrent.locks.Condition condition, java.util.Set<java.util.concurrent.Future<?>> futuresToFinish, java.util.concurrent.Callable<V> callable)
channel
- The channel that messages are sent downunfinishedLock
- The lock which protects the futuresToFinish
set object.condition
- The condition to signal when this future finishesfuturesToFinish
- The set to remove this future from when
it is finished.callable
- The callable to actually run on the server sidepublic DistributedFuture(Channel channel, java.util.concurrent.locks.Lock unfinishedLock, java.util.concurrent.locks.Condition condition, java.util.Set<java.util.concurrent.Future<?>> futuresToFinish, java.lang.Runnable runnable, V result)
channel
- The channel that messages are sent downunfinishedLock
- The lock which protects the futuresToFinish
set object.condition
- The condition to signal when this future finishesfuturesToFinish
- The set to remove this future from when
it is finished.runnable
- the runnable taskresult
- the result to return on successful completion. If
you don't need a particular result, consider using
constructions of the form:
Future<?> f = new FutureTask<Object>(runnable, null)java.lang.NullPointerException
- if runnable is nullpublic java.lang.String toString()
toString
in class java.lang.Object
public java.util.concurrent.Callable<V> getCallable()
public boolean isCancelled()
isCancelled
in interface java.util.concurrent.Future<V>
public boolean isDone()
isDone
in interface java.util.concurrent.Future<V>
public boolean cancel(boolean mayInterruptIfRunning)
cancel
in interface java.util.concurrent.Future<V>
public V get() throws java.lang.InterruptedException, java.util.concurrent.ExecutionException
get
in interface java.util.concurrent.Future<V>
java.util.concurrent.CancellationException
java.lang.InterruptedException
java.util.concurrent.ExecutionException
public V 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<V>
java.util.concurrent.CancellationException
java.lang.InterruptedException
java.util.concurrent.ExecutionException
java.util.concurrent.TimeoutException
protected void done()
public NotifyingFuture<V> setListener(FutureListener<V> listener)
NotifyingFuture
setListener
in interface NotifyingFuture<V>
listener
- listener to attachprotected void set(V v)
v
- the valueprotected void setException(java.lang.Throwable t)
t
- the cause of failurepublic void run()
run
in interface java.lang.Runnable
run
in interface java.util.concurrent.RunnableFuture<V>
public void resultReturned(java.lang.Object obj)
resultReturned
in interface ExecutorNotification
public void throwableEncountered(java.lang.Throwable t)
throwableEncountered
in interface ExecutorNotification
public void interrupted(java.lang.Runnable runnable)
interrupted
in interface ExecutorNotification
Copyright © 1998-2020 Red Hat. All Rights Reserved.