public class GridFutureAdapter<R> extends AbstractQueuedSynchronizer implements IgniteInternalFuture<R>
AbstractQueuedSynchronizer.ConditionObject
Constructor and Description |
---|
GridFutureAdapter() |
Modifier and Type | Method and Description |
---|---|
boolean |
cancel()
Default no-op implementation that always returns
false . |
<T> IgniteInternalFuture<T> |
chain(IgniteClosure<? super IgniteInternalFuture<R>,T> doneCb)
Make a chained future to convert result of this future (when complete) into a new format.
|
<T> IgniteInternalFuture<T> |
chain(IgniteClosure<? super IgniteInternalFuture<R>,T> doneCb,
Executor exec)
Make a chained future to convert result of this future (when complete) into a new format.
|
long |
duration()
Gets duration in milliseconds between start of the future and current time if future
is not finished, or between start and finish of this future.
|
long |
endTime() |
Throwable |
error() |
R |
get()
Synchronously waits for completion of the computation and
returns computation result.
|
R |
get(long timeout)
Synchronously waits for completion of the computation for
up to the timeout specified and returns computation result.
|
R |
get(long timeout,
TimeUnit unit)
Synchronously waits for completion of the computation for
up to the timeout specified and returns computation result.
|
protected R |
get0(long nanosTimeout) |
R |
getUninterruptibly()
Synchronously waits for completion of the computation and returns computation result ignoring interrupts.
|
void |
ignoreInterrupts(boolean ignoreInterrupts) |
boolean |
isCancelled()
Returns
true if this computation was cancelled before it completed normally. |
boolean |
isDone()
Checks if computation is done.
|
boolean |
isFailed() |
void |
listen(IgniteInClosure<? super IgniteInternalFuture<R>> lsnr0)
Registers listener closure to be asynchronously notified whenever future completes.
|
IgniteLogger |
logger() |
boolean |
onCancelled()
Callback to notify that future is cancelled.
|
boolean |
onDone()
Callback to notify that future is finished with
null result. |
boolean |
onDone(R res)
Callback to notify that future is finished.
|
boolean |
onDone(R res,
Throwable err)
Callback to notify that future is finished.
|
boolean |
onDone(Throwable err)
Callback to notify that future is finished.
|
R |
result() |
long |
startTime()
Gets start time for this future.
|
String |
toString() |
protected int |
tryAcquireShared(int ignore) |
protected boolean |
tryReleaseShared(int ignore) |
acquire, acquireInterruptibly, acquireShared, acquireSharedInterruptibly, compareAndSetState, getExclusiveQueuedThreads, getFirstQueuedThread, getQueuedThreads, getQueueLength, getSharedQueuedThreads, getState, getWaitingThreads, getWaitQueueLength, hasContended, hasQueuedPredecessors, hasQueuedThreads, hasWaiters, isHeldExclusively, isQueued, owns, release, releaseShared, setState, tryAcquire, tryAcquireNanos, tryAcquireSharedNanos, tryRelease
getExclusiveOwnerThread, setExclusiveOwnerThread
public long startTime()
startTime
in interface IgniteInternalFuture<R>
public long duration()
duration
in interface IgniteInternalFuture<R>
public void ignoreInterrupts(boolean ignoreInterrupts)
ignoreInterrupts
- Ignore interrupts flag.public long endTime()
public Throwable error()
error
in interface IgniteInternalFuture<R>
public R result()
result
in interface IgniteInternalFuture<R>
public R get() throws IgniteCheckedException
get
in interface IgniteInternalFuture<R>
IgniteInterruptedCheckedException
- Subclass of IgniteCheckedException
thrown if the wait was interrupted.IgniteFutureCancelledCheckedException
- Subclass of IgniteCheckedException
throws if computation was cancelled.IgniteCheckedException
- If computation failed.public R getUninterruptibly() throws IgniteCheckedException
getUninterruptibly
in interface IgniteInternalFuture<R>
IgniteFutureCancelledCheckedException
- Subclass of IgniteCheckedException
throws if computation
was cancelled.IgniteCheckedException
- If computation failed.public R get(long timeout) throws IgniteCheckedException
get(long, TimeUnit.MILLISECONDS)
.get
in interface IgniteInternalFuture<R>
timeout
- The maximum time to wait in milliseconds.IgniteInterruptedCheckedException
- Subclass of IgniteCheckedException
thrown if the wait was interrupted.IgniteFutureTimeoutCheckedException
- Subclass of IgniteCheckedException
thrown if the wait was timed out.IgniteFutureCancelledCheckedException
- Subclass of IgniteCheckedException
throws if computation was cancelled.IgniteCheckedException
- If computation failed.public R get(long timeout, TimeUnit unit) throws IgniteCheckedException
get
in interface IgniteInternalFuture<R>
timeout
- The maximum time to wait.unit
- The time unit of the timeout
argument.IgniteInterruptedCheckedException
- Subclass of IgniteCheckedException
thrown if the wait was interrupted.IgniteFutureTimeoutCheckedException
- Subclass of IgniteCheckedException
thrown if the wait was timed out.IgniteFutureCancelledCheckedException
- Subclass of IgniteCheckedException
throws if computation was cancelled.IgniteCheckedException
- If computation failed.@Nullable protected R get0(long nanosTimeout) throws InterruptedException, IgniteCheckedException
nanosTimeout
- Timeout (nanoseconds).InterruptedException
- If interrupted.IgniteFutureTimeoutCheckedException
- If timeout reached before computation completed.IgniteCheckedException
- If error occurred.public void listen(IgniteInClosure<? super IgniteInternalFuture<R>> lsnr0)
listen
in interface IgniteInternalFuture<R>
lsnr0
- Listener closure to register. If not provided - this method is no-op.public <T> IgniteInternalFuture<T> chain(IgniteClosure<? super IgniteInternalFuture<R>,T> doneCb)
chain
in interface IgniteInternalFuture<R>
doneCb
- Done callback that is applied to this future when it finishes to produce chained future result.public <T> IgniteInternalFuture<T> chain(IgniteClosure<? super IgniteInternalFuture<R>,T> doneCb, Executor exec)
chain
in interface IgniteInternalFuture<R>
doneCb
- Done callback that is applied to this future when it finishes to produce chained future result.exec
- Executor to run callback.public boolean cancel() throws IgniteCheckedException
false
.
Futures that do support cancellation should override this method
and call onCancelled()
callback explicitly if cancellation
indeed did happen.cancel
in interface IgniteInternalFuture<R>
True
if future was canceled (i.e. was not finished prior to this call).IgniteCheckedException
- If cancellation failed.public boolean isDone()
isDone
in interface IgniteInternalFuture<R>
True
if computation is done, false
otherwise.public boolean isFailed()
public boolean isCancelled()
true
if this computation was cancelled before it completed normally.isCancelled
in interface IgniteInternalFuture<R>
True
if this computation was cancelled before it completed normally.public final boolean onDone()
null
result.
This method must delegate to onDone(Object, Throwable)
method.True
if result was set by this call.public final boolean onDone(@Nullable R res)
onDone(Object, Throwable)
method.res
- Result.True
if result was set by this call.public final boolean onDone(@Nullable Throwable err)
onDone(Object, Throwable)
method.err
- Error.True
if result was set by this call.public boolean onDone(@Nullable R res, @Nullable Throwable err)
null
exception is passed in
the result value will be ignored.res
- Optional result.err
- Optional error.True
if result was set by this call.public boolean onCancelled()
True
if cancel flag was set by this call.protected final int tryAcquireShared(int ignore)
tryAcquireShared
in class AbstractQueuedSynchronizer
protected final boolean tryReleaseShared(int ignore)
tryReleaseShared
in class AbstractQueuedSynchronizer
@Nullable public IgniteLogger logger()
public String toString()
toString
in class AbstractQueuedSynchronizer
Follow @ApacheIgnite
Ignite Fabric : ver. 1.9.0 Release Date : March 2 2017