Package java.util.concurrent

Examples of java.util.concurrent.CancellationException


      }
     
      private V innerGet(long timeout, TimeUnit unit)
            throws ExecutionException, TimeoutException, InterruptedException {
         if (isCancelled())
            throw new CancellationException("Task already cancelled");

         long timeoutNanos = computeTimeoutNanos(timeout, unit);
         long endNanos = System.nanoTime() + timeoutNanos;
         V response;
         try {
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 boolean cancel(boolean mayInterruptIfRunning) {

        LOG.debug("Attempting to cancel");

        CancellationException ce = null;
        synchronized (latch) {
            if (!isCancelled() && !isDone() && cancelOwner(mayInterruptIfRunning)) {

                LOG.debug("Successfully cancelled");

                ce = new CancellationException();
                result.set(ce);
            } else {
                LOG.debug("Unable to cancel");
            }
View Full Code Here

        LOG.trace("Entering wait");
        latch.await();
        LOG.trace("Wait completed");

        if (isCancelled()) {
            throw new CancellationException();
        }

        Object object = result.get();

        if (object instanceof ExecutionException) {
View Full Code Here

        }

        LOG.trace("Wait completed");

        if (isCancelled()) {
            throw new CancellationException();
        }

        Object object = result.get();

        if (object instanceof ExecutionException) {
View Full Code Here

           
            if (clearList) {
                tilesToDraw_queue.clear();
            }
           
            throw new CancellationException();
        }
    }
View Full Code Here

    @Override
    public void run() {
      MapMakerInternalMap<?, ?> map = mapReference.get();
      if (map == null) {
        throw new CancellationException();
      }

      for (Segment<?, ?> segment : map.segments) {
        segment.runCleanup();
      }
View Full Code Here

                // Wait for removal to complete
                while (map.containsKey(name)) try {
                    map.wait();
                } catch (InterruptedException ex) {
                    Thread.currentThread().interrupt();
                    throw new CancellationException("Service install was cancelled");
                }
                boolean intr = false;
                try {
                    while (map.containsKey(name)) try {
                        map.wait();
                        return realBuilder.install();
                    } catch (InterruptedException e) {
                        if (respectInterruption) {
                            Thread.currentThread().interrupt();
                            throw new CancellationException("Service install was cancelled");
                        } else {
                            intr = true;
                        }
                    }
                } finally {
View Full Code Here

            try {
                modelController.acquireLock(respectInterruption);
                lockDepth = depth;
            } catch (InterruptedException e) {
                Thread.currentThread().interrupt();
                throw new CancellationException("Operation cancelled asynchronously");
            }
        }
    }
View Full Code Here

    private void awaitContainerMonitor() {
        try {
            modelController.awaitContainerMonitor(respectInterruption, 1);
        } catch (InterruptedException e) {
            Thread.currentThread().interrupt();
            throw new CancellationException("Operation cancelled asynchronously");
        }
    }
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.