Package java.util.concurrent

Examples of java.util.concurrent.CancellationException


   public final V get() throws InterruptedException, ExecutionException {
      int s = (Thread.currentThread() instanceof ForkJoinWorkerThread) ?
            doJoin() : externalInterruptibleAwaitDone();
      Throwable ex;
      if ((s &= DONE_MASK) == CANCELLED)
         throw new CancellationException();
      if (s == EXCEPTIONAL && (ex = getThrowableException()) != null)
         throw new ExecutionException(ex);
      return getRawResult();
   }
View Full Code Here


            throw new InterruptedException();
      }
      if ((s &= DONE_MASK) != NORMAL) {
         Throwable ex;
         if (s == CANCELLED)
            throw new CancellationException();
         if (s != EXCEPTIONAL)
            throw new TimeoutException();
         if ((ex = getThrowableException()) != null)
            throw new ExecutionException(ex);
      }
View Full Code Here

      }

      @Override
      public R get() throws InterruptedException, ExecutionException {
         if (isCancelled())
            throw new CancellationException("MapReduceTask already cancelled");
         try {
            return call.call();
         } catch (Exception e) {
            throw new ExecutionException(e);
         } finally {
View Full Code Here

      }

      @Override
      public R get() throws InterruptedException, ExecutionException {
         if (isCancelled())
            throw new CancellationException("MapReduceTask already cancelled");
         try {
            return call.call();
         } catch (Exception e) {
            throw new ExecutionException(e);
         } finally {
View Full Code Here

   * propagated back to the scheduler pool, will disable the wrapper task.
   * Therefore, ensure that you do not accidentally catch this exception by a
   * <code>catch (Throwable ex)</code> clause.</p>
   */
  protected void cancel() {
    throw new CancellationException(); // FIXME there seems to be no more elegant way than this
  }
View Full Code Here

   
    @Override
    public boolean cancel(boolean mayInterruptIfRunning) {
        boolean result = super.cancel(mayInterruptIfRunning);
        if (result && handler != null) {
            handler.failed(new ClientException(new CancellationException()));
        }
        return result;
    }
View Full Code Here

    public T get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException {
     
      ArrayBlockingQueue<Object> localRQ = resultQueue;
     
      if (state.get() == CANCELED)
        throw new CancellationException();
     
      if (localRQ == null && state.get() == ADDED)
        throw new IllegalStateException("Tried to get result twice");
     
      Object r = localRQ.poll(timeout, unit);
     
      // could have been canceled while waiting
      if (state.get() == CANCELED) {
        if (r != null)
          throw new IllegalStateException("Nothing should have been added when in canceled state");
       
        throw new CancellationException();
      }
     
      if (r == null)
        throw new TimeoutException();
     
View Full Code Here

        }

        @Override
        public CancellationException cancel() {
            monitor.setCanceled(true);
            return new CancellationException();
        }
View Full Code Here

    if (finished) return;

    this.finished = true;
    LOG.info("Stop taking snapshot=" + ClientSnapshotDescriptionUtils.toString(snapshot) +
        " because: " + why);
    CancellationException ce = new CancellationException(why);
    monitor.receive(new ForeignException(master.getServerName().toString(), ce));
  }
View Full Code Here

    }
  }

  static final CancellationException cancellationExceptionWithCause(
      @Nullable String message, @Nullable Throwable cause) {
    CancellationException exception = new CancellationException(message);
    exception.initCause(cause);
    return exception;
  }
View Full Code Here

TOP

Related Classes of java.util.concurrent.CancellationException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.