Package com.opengamma.util.async

Examples of com.opengamma.util.async.Cancelable


  public void testCancelStoppingJobs() {
    final AtomicBoolean canceled = new AtomicBoolean();
    final JobDispatcher dispatcher = new JobDispatcher() {
      @Override
      public Cancelable dispatchJob(final CalculationJob job, final JobResultReceiver receiver) {
        return new Cancelable() {
          @Override
          public boolean cancel(final boolean mayInterruptIfRunning) {
            assertTrue(mayInterruptIfRunning);
            canceled.set(true);
            return true;
View Full Code Here


    // No third job
    assertNull(dispatcher.pollResult());
  }

  public void testCancelDuringDispatch() {
    final Cancelable handle = Mockito.mock(Cancelable.class);
    final AtomicReference<PlanExecutor> executor = new AtomicReference<PlanExecutor>();
    final JobDispatcher dispatcher = new JobDispatcher() {
      @Override
      public Cancelable dispatchJob(final CalculationJob job, final JobResultReceiver receiver) {
        executor.get().cancel(true);
View Full Code Here

    s_logger.info("testJobCancel");
    final JobDispatcher jobDispatcher = new JobDispatcher();
    jobDispatcher.setMaxJobExecutionTime(2 * TIMEOUT);
    jobDispatcher.setMaxJobAttempts(1);
    final TestJobResultReceiver result = new TestJobResultReceiver();
    Cancelable job = jobDispatcher.dispatchJob(createTestJob(), result);
    assertNotNull(job);
    assertNull(result.getResult());
    final BlockingJobInvoker blockingInvoker = new BlockingJobInvoker(TIMEOUT);
    jobDispatcher.registerJobInvoker(blockingInvoker);
    assertTrue (job.cancel (false));
    assertTrue (blockingInvoker.isCancelled ());
  }
View Full Code Here

      _executing.put(job.getSpecification(), executing);
      if (job.getTail() != null) {
        storeTailJobs(job);
      }
    }
    final Cancelable handle = getCycle().getViewProcessContext().getComputationJobDispatcher().dispatchJob(job, this);
    executing.setCancel(handle);
    synchronized (this) {
      if (_executing == null) {
        // Completed or cancelled during the submission
        handle.cancel(true);
        return;
      }
      if (job.getTail() != null) {
        cancelableTailJobs(job, handle);
      }
View Full Code Here

    // Cancelable

    @Override
    public boolean cancel(final boolean mayInterruptedIfRunning) {
      Cancelable cancel = getCancel();
      if (cancel != null) {
        s_logger.debug("Cancelling {} for job {}", _cancel, _job);
        return cancel.cancel(mayInterruptedIfRunning);
      } else {
        return false;
      }
    }
View Full Code Here

TOP

Related Classes of com.opengamma.util.async.Cancelable

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.