Class GridFutureAdapter<R>

    • Constructor Detail

      • GridFutureAdapter

        public GridFutureAdapter()
    • Method Detail

      • ignoreInterrupts

        public void ignoreInterrupts()
        Determines whether the future will ignore interrupts while waiting for result in get() methods. This call should happen before subsequent get() in order to have guaranteed effect.
      • result

        public R result()
        Specified by:
        result in interface IgniteInternalFuture<R>
        Returns:
        Result value if future has already been completed normally.
      • listen

        public void listen​(IgniteRunnable lsnr)
        Registers listener closure to be asynchronously notified whenever future completes.
        Specified by:
        listen in interface IgniteInternalFuture<R>
        Parameters:
        lsnr - Listener closure to register.
      • chain

        public <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. It is guaranteed that done callback will be called only ONCE.
        Specified by:
        chain in interface IgniteInternalFuture<R>
        Parameters:
        doneCb - Done callback that is applied to this future when it finishes to produce chained future result.
        Returns:
        Chained future that finishes after this future completes and done callback is called.
      • chain

        public <T> IgniteInternalFuture<T> chain​(IgniteOutClosure<T> doneCb)
        Make a chained future to convert result of this future (when complete) into a new format. It is guaranteed that done callback will be called only ONCE.
        Specified by:
        chain in interface IgniteInternalFuture<R>
        Parameters:
        doneCb - Done callback that is applied to this future when it finishes to produce chained future result.
        Returns:
        Chained future that finishes after this future completes and done callback is called.
      • chain

        public <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. It is guaranteed that done callback will be called only ONCE.
        Specified by:
        chain in interface IgniteInternalFuture<R>
        Parameters:
        doneCb - Done callback that is applied to this future when it finishes to produce chained future result.
        exec - Executor to run callback.
        Returns:
        Chained future that finishes after this future completes and done callback is called.
      • chain

        public <T> IgniteInternalFuture<T> chain​(IgniteOutClosure<T> doneCb,
                                                 Executor exec)
        Make a chained future to convert result of this future (when complete) into a new format. It is guaranteed that done callback will be called only ONCE.
        Specified by:
        chain in interface IgniteInternalFuture<R>
        Parameters:
        doneCb - Done callback that is applied to this future when it finishes to produce chained future result.
        exec - Executor to run callback.
        Returns:
        Chained future that finishes after this future completes and done callback is called.
      • chainCompose

        public <T> IgniteInternalFuture<T> chainCompose​(IgniteClosure<? super IgniteInternalFuture<R>,​IgniteInternalFuture<T>> doneCb,
                                                        @Nullable
                                                        @Nullable Executor exec)
        Make a chained future that is completed when doneCb is executed. Callback is called with this future as the argument, when this future completes. It is guaranteed that done callback will be called only ONCE.
        Specified by:
        chainCompose in interface IgniteInternalFuture<R>
        Type Parameters:
        T - Type parameter.
        Parameters:
        doneCb - Done callback.
        exec - Executor to run callback.
        Returns:
        Chained future.
      • logger

        @Nullable
        public @Nullable IgniteLogger logger()
        Returns:
        Logger instance.
      • cancel

        public boolean cancel()
                       throws IgniteCheckedException
        Default no-op implementation that always returns false. Futures that do support cancellation should override this method and call onCancelled() callback explicitly if cancellation indeed did happen.
        Specified by:
        cancel in interface IgniteInternalFuture<R>
        Returns:
        True if future was canceled (i.e. was not finished prior to this call).
        Throws:
        IgniteCheckedException - If cancellation failed.
      • isDone

        public boolean isDone()
        Checks if computation is done.
        Specified by:
        isDone in interface IgniteInternalFuture<R>
        Returns:
        True if computation is done, false otherwise.
      • isFailed

        public boolean isFailed()
        Returns:
        True if future is completed with exception.
      • isCancelled

        public boolean isCancelled()
        Returns true if this computation was cancelled before it completed normally.
        Specified by:
        isCancelled in interface IgniteInternalFuture<R>
        Returns:
        True if this computation was cancelled before it completed normally.
      • onDone

        public final boolean onDone()
        Callback to notify that future is finished with null result. This method must delegate to onDone(Object, Throwable) method.
        Returns:
        True if result was set by this call.
      • onDone

        public final boolean onDone​(@Nullable
                                    R res)
        Callback to notify that future is finished. This method must delegate to onDone(Object, Throwable) method.
        Parameters:
        res - Result.
        Returns:
        True if result was set by this call.
      • onDone

        public final boolean onDone​(@Nullable
                                    @Nullable Throwable err)
        Callback to notify that future is finished. This method must delegate to onDone(Object, Throwable) method.
        Parameters:
        err - Error.
        Returns:
        True if result was set by this call.
      • onDone

        public boolean onDone​(@Nullable
                              R res,
                              @Nullable
                              @Nullable Throwable err)
        Callback to notify that future is finished. Note that if non-null exception is passed in the result value will be ignored.
        Parameters:
        res - Optional result.
        err - Optional error.
        Returns:
        True if result was set by this call.
      • onDone

        protected boolean onDone​(@Nullable
                                 R res,
                                 @Nullable
                                 @Nullable Throwable err,
                                 boolean cancel)
        Parameters:
        res - Result.
        err - Error.
        cancel - True if future is being cancelled.
        Returns:
        True if result was set by this call.
      • reset

        public void reset()
        Resets future for subsequent reuse.
      • onCancelled

        public boolean onCancelled()
        Callback to notify that future is cancelled.
        Returns:
        True if cancel flag was set by this call.