/**
   * @param nanosTimeout Timeout (nanoseconds).
   * @return Result.
   * @throws InterruptedException If interrupted.
   * @throws IgniteFutureTimeoutCheckedException If timeout reached before computation completed.
   * @throws IgniteCheckedException If error occurred.
   */
  @Nullable
  protected R get0(long nanosTimeout) throws InterruptedException, IgniteCheckedException {
    if (endTime == 0 && !tryAcquireSharedNanos(0, nanosTimeout))
      throw new IgniteFutureTimeoutCheckedException(
          "Timeout was reached before computation completed.");

    if (getState() == CANCELLED)
      throw new IgniteFutureCancelledCheckedException("Future was cancelled: " + this);

    assert resFlag != 0;

    if (resFlag == ERR) throw U.cast((Throwable) res);

    return (R) res;
  }
  /** {@inheritDoc} */
  @Override
  public R get() throws IgniteCheckedException {
    try {
      if (endTime == 0) {
        if (ignoreInterrupts) acquireShared(0);
        else acquireSharedInterruptibly(0);
      }

      if (getState() == CANCELLED)
        throw new IgniteFutureCancelledCheckedException("Future was cancelled: " + this);

      assert resFlag != 0;

      if (resFlag == ERR) throw U.cast((Throwable) res);

      return (R) res;
    } catch (InterruptedException e) {
      Thread.currentThread().interrupt();

      throw new IgniteInterruptedCheckedException(e);
    }
  }