public class GridFutureAdapterEx<R> extends AbstractQueuedSynchronizer implements IgniteInternalFuture<R>, Externalizable
AbstractQueuedSynchronizer.ConditionObject| Constructor and Description |
|---|
GridFutureAdapterEx()
Empty constructor required for
Externalizable. |
| 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.
|
protected void |
checkValid()
Checks that future is in usable state.
|
boolean |
concurrentNotify()
Gets value concurrent listener notification flag.
|
void |
concurrentNotify(boolean concurNotify)
Flag to turn on or off concurrent listener notification.
|
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.
|
protected 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) |
boolean |
isCancelled()
Returns
true if this computation was cancelled before it completed normally. |
boolean |
isDone()
Checks if computation is done.
|
protected boolean |
isValid() |
void |
listenAsync(IgniteInClosure<? super IgniteInternalFuture<R>> lsnr)
Registers listener closure to be asynchronously notified whenever future completes.
|
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.
|
void |
readExternal(ObjectInput in) |
protected R |
result() |
long |
startTime()
Gets start time for this future.
|
void |
stopListenAsync(IgniteInClosure<? super IgniteInternalFuture<R>>... lsnr)
Removes given listeners from the future.
|
boolean |
syncNotify()
Gets value of synchronous listener notification flag.
|
void |
syncNotify(boolean syncNotify)
Flag to turn on or off synchronous listener notification.
|
String |
toString() |
protected int |
tryAcquireShared(int ignore) |
protected boolean |
tryReleaseShared(int ignore) |
void |
writeExternal(ObjectOutput out) |
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, tryReleasegetExclusiveOwnerThread, setExclusiveOwnerThreadpublic GridFutureAdapterEx()
Externalizable.public long startTime()
startTime in interface IgniteInternalFuture<R>public long duration()
duration in interface IgniteInternalFuture<R>public boolean concurrentNotify()
true,
then all listeners will be notified concurrently by different threads; otherwise,
listeners will be notified one after another within one thread (depending on
IgniteInternalFuture.syncNotify() flag, these notifications may happen either in the same thread which
started the future, or in a different thread).
Default value is false. To change the default, set
IgniteSystemProperties.IGNITE_FUT_CONCURRENT_NOTIFICATION system property to true.
concurrentNotify in interface IgniteInternalFuture<R>public void concurrentNotify(boolean concurNotify)
true,
then all listeners will be notified concurrently by different threads; otherwise,
listeners will be notified one after another within one thread (depending on
IgniteInternalFuture.syncNotify() flag, these notifications may happen either in the same thread which
started the future, or in a different thread).
Default value is false. To change the default, set
IgniteSystemProperties.IGNITE_FUT_CONCURRENT_NOTIFICATION system property to true.
concurrentNotify in interface IgniteInternalFuture<R>concurNotify - Flag to turn on or off concurrent listener notification.public boolean syncNotify()
true, then
upon future completion the notification may happen in the same thread that created
the future. This becomes especially important when adding listener to a future that
is already done - if this flag is true, then listener will be
immediately notified within the same thread.
Default value is false. To change the default, set
IgniteSystemProperties.IGNITE_FUT_SYNC_NOTIFICATION system property to true.
syncNotify in interface IgniteInternalFuture<R>public void syncNotify(boolean syncNotify)
true, then
upon future completion the notification may happen in the same thread that created
the future. This becomes especially important when adding listener to a future that
is already done - if this flag is true, then listener will be
immediately notified within the same thread.
Default value is false. To change the default, set
IgniteSystemProperties.IGNITE_FUT_SYNC_NOTIFICATION system property to true.
syncNotify in interface IgniteInternalFuture<R>syncNotify - Flag to turn on or off synchronous listener notification.protected void checkValid()
protected boolean isValid()
protected Throwable error()
protected R result()
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 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 listenAsync(@Nullable IgniteInClosure<? super IgniteInternalFuture<R>> lsnr)
listenAsync in interface IgniteInternalFuture<R>lsnr - Listener closure to register. If not provided - this method is no-op.public void stopListenAsync(@Nullable IgniteInClosure<? super IgniteInternalFuture<R>>... lsnr)
stopListenAsync in interface IgniteInternalFuture<R>lsnr - Listeners to remove.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 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 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 AbstractQueuedSynchronizerprotected final boolean tryReleaseShared(int ignore)
tryReleaseShared in class AbstractQueuedSynchronizerpublic void writeExternal(ObjectOutput out) throws IOException
writeExternal in interface ExternalizableIOExceptionpublic void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
readExternal in interface ExternalizableIOExceptionClassNotFoundExceptionpublic String toString()
toString in class AbstractQueuedSynchronizer
Follow @ApacheIgnite
Ignite Fabric : ver. 1.0.0-RC1 Release Date : February 17 2015