Cancels all tasks via their {@link ChainedDriver#cancelTask()} method. Any occurring exception
and error is suppressed, such that the canceling method of every task is invoked in all cases.

@param tasks The tasks to be canceled.
548783
public static void cancelChainedTasks(List<ChainedDriver<?, ?>> tasks) {
		for (int i = 0; i < tasks.size(); i++) {
			try {
				tasks.get(i).cancelTask();
			} catch (Throwable t) {
				// do nothing
			}
		}
	}
1203269
public static synchronized void cancel(TimerTask task) {
        if (task == null) {
            return;
        }
        task.cancel();
        usageCount.decrementAndGet();
        if (usageCount.get() == 0) {
            timer.cancel();
            timer = null;
        }
    }
1000039
public static void killAll()
  {
    Collection<TaskQueue> taskQueues = new ArrayList<TaskQueue>( QUEUE_MAP.values() );
    for( TaskQueue taskQueue : taskQueues )
    {
      emptyAndRemoveQueue( taskQueue.getName() );
    }
  }
325190
public synchronized boolean cancel() {
    if (this.taskFuture != null && this.taskFuture.cancel(true)) {
      this.taskStateTracker.onTaskRunCompletion(this);
      this.completeShutdown();
      return true;
    } else {
      return false;
    }
  }
790189
public void removeTask(AgentTask task) {
		final Iterator<WeakReference<AgentTask>> iterator = this.tasks.iterator();
		while (iterator.hasNext()) {
			final WeakReference<AgentTask> reference = iterator.next();
			final AgentTask knownTask = reference.get();
			if (knownTask == null) {
				iterator.remove();
			} else if (Objects.equals(knownTask.getName(), task.getName())) {
				iterator.remove();
				return;
			}
		}
	}
120004
public <T> T execute(Task<T> task) {
        synchronized(task) {
            task.reset();
            // add it to the tail
            taskList.add(task);

            // invoke the execution
            lock.activate();

            // wait for the completion
            try {
            	while (!task.isDone()) {
            		task.wait();
            	}
            } catch (InterruptedException e) {
                task.exception = e; // we got interrupted, so task.result will be invalid! 
            }

            if(task.exception!=null) {
                Throwable e = task.exception;
                task.exception = null;
                throw new ExecutionException(e);
            } else {
                T r = task.result;
                task.result = null;
                return r;
            }
        }
    }
1040101
@Override
    public void execute(Runnable task) {
        // count a new task in process
        tasksInProcess.incrementAndGet();
        try {
            super.execute(task);
        } catch (RuntimeException e) { // specifically handle RejectedExecutionException
            tasksInProcess.decrementAndGet();
            throw e;
        } catch (Error e) {
            tasksInProcess.decrementAndGet();
            throw e;
        }
    }
414516
public TaskCancelResult cancelTask() {

		while (true) {

			final ExecutionState previousState = this.executionState.get();

			if (previousState == ExecutionState.CANCELED) {
				return new TaskCancelResult(getID(), AbstractTaskResult.ReturnCode.SUCCESS);
			}

			if (previousState == ExecutionState.FAILED) {
				return new TaskCancelResult(getID(), AbstractTaskResult.ReturnCode.SUCCESS);
			}

			if (previousState == ExecutionState.FINISHED) {
				return new TaskCancelResult(getID(), AbstractTaskResult.ReturnCode.SUCCESS);
			}

			// The vertex has already received a cancel request
			if (previousState == ExecutionState.CANCELING) {
				return new TaskCancelResult(getID(), ReturnCode.SUCCESS);
			}

			// Do not trigger the cancel request when vertex is in state STARTING, this might cause a race between RPC
			// calls.
			if (previousState == ExecutionState.STARTING) {

				this.cancelRequested.set(true);

				// We had a race, so we unset the flag and take care of cancellation ourselves
				if (this.executionState.get() != ExecutionState.STARTING) {
					this.cancelRequested.set(false);
					continue;
				}

				return new TaskCancelResult(getID(), AbstractTaskResult.ReturnCode.SUCCESS);
			}

			// Check if we had a race. If state change is accepted, send cancel request
			if (compareAndUpdateExecutionState(previousState, ExecutionState.CANCELING)) {

				if (this.groupVertex.getStageNumber() != this.executionGraph.getIndexOfCurrentExecutionStage()) {
					// Set to canceled directly
					updateExecutionState(ExecutionState.CANCELED, null);
					return new TaskCancelResult(getID(), AbstractTaskResult.ReturnCode.SUCCESS);
				}

				if (previousState != ExecutionState.RUNNING && previousState != ExecutionState.FINISHING) {
					// Set to canceled directly
					updateExecutionState(ExecutionState.CANCELED, null);
					return new TaskCancelResult(getID(), AbstractTaskResult.ReturnCode.SUCCESS);
				}

				final AllocatedResource ar = this.allocatedResource.get();

				if (ar == null) {
					final TaskCancelResult result = new TaskCancelResult(getID(),
						AbstractTaskResult.ReturnCode.NO_INSTANCE);
					result.setDescription("Assigned instance of vertex " + this.toString() + " is null!");
					return result;
				}

				try {
					return ar.getInstance().cancelTask(this.vertexID);

				} catch (IOException e) {
					final TaskCancelResult result = new TaskCancelResult(getID(),
						AbstractTaskResult.ReturnCode.IPC_ERROR);
					result.setDescription(StringUtils.stringifyException(e));
					return result;
				}
			}
		}
	}
257444
public void setBundleTasks(java.util.Collection<BundleTask> bundleTasks) {
        if (bundleTasks == null) {
            this.bundleTasks = null;
            return;
        }

        this.bundleTasks = new com.amazonaws.internal.SdkInternalList<BundleTask>(bundleTasks);
    }
1041559
public boolean cancel(T task) {
    CancellableTask<K, T> cancellableTask = this.cancellableTaskMap.getIfPresent(task.getKey());
    if (cancellableTask != null && cancellableTask.getScheduledTask() == task && cancellableTask.cancel()) {
      this.cancellableTaskMap.invalidate(task.getKey());
      return true;
    }
    return false;
  }
1084725
public void cancelQueuedTasks() {
      ArrayList<QueueingTask> queuedTasks = new ArrayList<QueueingTask>();
      queue.drainTo(queuedTasks);
      for (QueueingTask task : queuedTasks) {
         task.cancel(false);
      }
   }
1310675
public void abort(Throwable t) {
        // Set the result to the given exception
        boolean abortSuccessful = getResultFuture().completeExceptionally(t);

        if (abortSuccessful) {
            // Attempt to abort the task
            getTaskFuture().cancel(true);
        }
    }
432101
public void remove(final Task task)
  {
    giant.lock();
    try {
      try {
        log.info("Removing task[%s] from activeTasks", task.getId());
        for (final TaskLockPosse taskLockPosse : findLockPossesForTask(task)) {
          unlock(task, taskLockPosse.getTaskLock().getInterval());
        }
      }
      finally {
        activeTasks.remove(task.getId());
      }
    }
    finally {
      giant.unlock();
    }
  }
246346
public static void cancelTasksByGroup(Context context, int groupId, int reason,
      CancelListener cancelListener) {
    cancelTasks(context, GroundyService.class, groupId, reason, cancelListener);
  }
849572
async def jsk_cancel(self, ctx: commands.Context, *, index: int):
        

        if not self.tasks:
            return await ctx.send("No tasks to cancel.")

        if index == -1:
            task = self.tasks.pop()
        else:
            task = discord.utils.get(self.tasks, index=index)
            if task:
                self.tasks.remove(task)
            else:
                return await ctx.send("Unknown task.")

        task.task.cancel()
        return await ctx.send(f"Cancelled task {task.index}: `{task.ctx.command.qualified_name}`,"
                              f" invoked at {task.ctx.message.created_at.strftime('%Y-%m-%d %H:%M:%S')} UTC")
319336
public List<Future<T>> execute(@SuppressWarnings("unchecked") Task<T> ... tasks) {
		List<Future<T>> futures = new ArrayList<Future<T>>();
		if(tasks != null) {
			synchronized(queue) {
				int i = 0;
				for(Task<T> task : tasks) {
					if(task !=  null) {
						this.tasks.add(task);
						TaskCallable<T> callable = new TaskCallable<T>(i++, queue, task);
						for(TaskObserver<T> observer : observers) {
							observer.onTaskStarting(task);
						}
						futures.add(executor.submit(callable));
						for(TaskObserver<T> observer : observers) {
							observer.onTaskStarted(task);
						}
					}
				}
			}
		}
		return futures;
	}
1202692
protected void cancelRunningChildren (int startIndex) {
		for (int i = startIndex, n = getChildCount(); i < n; i++) {
			Task<E> child = getChild(i);
			if (child.status == Status.RUNNING) child.cancel();
		}
	}