예제 #1
0
  /**
   * Cancels or kills the task.
   *
   * @param cancel <code>true/code> if the task shall be canceled, <code>false</code> if it shall be killed
   */
  private void cancelOrKillExecution() {
    if (!this.canceled.compareAndSet(false, true)) {
      return;
    }

    if (this.executionState != ExecutionState.RUNNING
        && this.executionState != ExecutionState.FINISHING) {
      return;
    }

    executionStateChanged(ExecutionState.CANCELING, null);

    // Request user code to shut down
    try {
      this.environment.cancelExecution();
    } catch (Throwable e) {
      LOG.error("Error while cancelling the task.", e);
    }
  }
예제 #2
0
 /** Marks the task as failed and triggers the appropriate state changes. */
 public void markAsFailed() {
   executionStateChanged(ExecutionState.FAILED, "Execution thread died unexpectedly");
 }