Adds task to the chain.

@param task
@param offset
967698
public void add(Task task) {
    	synchronized(LOCK) {
    		//terminated task will be selected immediately before start
    		task.setListener(this);
        
    		this.task[wi] = task;        
        
    		wi++;
    	}
    }
470767
@GuardedBy("evictionLock")
    void runTasks(Task[] tasks, int maxTaskIndex) {
        for (int i = 0; i <= maxTaskIndex; i++) {
            runTasksInChain(tasks[i]);
        }
    }
26744
@Override
    synchronized void offer(TransactionTask task)
    {
        Iv2Trace.logTransactionTaskQueueOffer(task);
        m_backlog.addLast(task);
        taskQueueOffer();
    }
1098911
@Override
    public void requeue(Task task) {
        this.inprocess.remove(task);
        task.incrementAttempts();
        this.queue.add(task);
    }
29717
def add_task(self, task):
        
        if not self._valid_name(task.name):
            raise ValueError(task.name)

        self._tasks[task.name] = task

        incomplete_dependencies = set()

        for dependency in task.dependencies:
            if not self._valid_name(dependency) or dependency in self._failed:
                # there may already be tasks dependent on this one.
                self._cascade_failure(task.name)

                break

            if dependency not in self._completed:
                incomplete_dependencies.add(dependency)
        else:  # task hasn't failed
            try:
                self._graph.add(task.name, incomplete_dependencies)
            except ValueError:
                self._cascade_failure(task.name)
549756
@VisibleForTesting
  RemoteTaskRunnerWorkItem addPendingTask(final Task task)
  {
    log.info("Added pending task %s", task.getId());
    final RemoteTaskRunnerWorkItem taskRunnerWorkItem = new RemoteTaskRunnerWorkItem(
        task.getId(),
        task.getType(),
        null,
        null,
        task.getDataSource()
    );
    pendingTaskPayloads.put(task.getId(), task);
    pendingTasks.put(task.getId(), taskRunnerWorkItem);
    runPendingTasks();
    return taskRunnerWorkItem;
  }
258898
public static void addTask(final TimerTask task, final long delay, final long period) {
        timer.scheduleAtFixedRate(task, delay, period);
    }
1123649
private void init(final Task<Revision> task)
	{
		this.partCounter++;
		this.result = new Task<Diff>(task.getHeader(), partCounter);
	}
1221767
public void addTask(ReceivedMessageTask task) {
        tasks.add(task);
        Packet packet = task.getPacket();
        // don't run the deadlock guard if timeout is <= 0
        if (packet.getExpirationTime() > 0L) {
            // run a deadlock guard so hanging tasks will be interrupted
            task.runDeadlockFuture(new DeadlockGuard(task));
        }
        if (listener != null) {
            listener.onTaskAdded(this);
        }
    }
132795
public void setTasks(java.util.Collection<AuditTaskMetadata> tasks) {
        if (tasks == null) {
            this.tasks = null;
            return;
        }

        this.tasks = new java.util.ArrayList<AuditTaskMetadata>(tasks);
    }
1019422
public static void processTask(Task task) {
    logger.finest("Processing task " + task);
    try {
      switch (task.getType()) {
        case RUN_JOB:
          runJob((RunJobTask) task);
          break;
        case HANDLE_SLOT_FILLED:
          handleSlotFilled((HandleSlotFilledTask) task);
          break;
        case FINALIZE_JOB:
          finalizeJob((FinalizeJobTask) task);
          break;
        case FAN_OUT:
          handleFanoutTaskOrAbandonTask((FanoutTask) task);
          break;
        case CANCEL_JOB:
          cancelJob((CancelJobTask) task);
          break;
        case DELETE_PIPELINE:
          DeletePipelineTask deletePipelineTask = (DeletePipelineTask) task;
          try {
            backEnd.deletePipeline(
                deletePipelineTask.getRootJobKey(), deletePipelineTask.shouldForce(), false);
          } catch (Exception e) {
            logger.log(Level.WARNING, "DeletePipeline operation failed.", e);
          }
          break;
        case HANDLE_CHILD_EXCEPTION:
          handleChildException((HandleChildExceptionTask) task);
          break;
        case DELAYED_SLOT_FILL:
          handleDelayedSlotFill((DelayedSlotFillTask) task);
          break;
        default:
          throw new IllegalArgumentException("Unrecognized task type: " + task.getType());
      }
    } catch (AbandonTaskException ate) {
      // return 200;
    }
  }
214668
private void setTasks(String tasks) {
		for (String task : tasks.split(",")) {
			if (KNOWN_TASKS.containsKey(task)) {
				this.tasks |= KNOWN_TASKS.get(task);
				this.taskName += (this.taskName.isEmpty() ? "" : "-") + task;
			} else {
				logger.warn("Unsupported RDF serialization task \"" + task
						+ "\". Run without specifying any tasks for help.");
			}
		}
	}
85795
public synchronized static void addShutdownHook(Runnable task) {
		if (task != null) {
			Runtime.getRuntime().addShutdownHook(new Thread(() -> {
				try {
					task.run();
				}
				catch (RuntimeException rex) {
					Say.warn("Exception while processing shutdown-hook", rex);
				}
			}));
		}
	}
439015
public void registerTask(Task task) throws IOException {
		final ResultPartition[] producedPartitions = task.getProducedPartitions();

		synchronized (lock) {
			if (isShutdown) {
				throw new IllegalStateException("NetworkEnvironment is shut down");
			}

			for (final ResultPartition partition : producedPartitions) {
				setupPartition(partition);
			}

			// Setup the buffer pool for each buffer reader
			final SingleInputGate[] inputGates = task.getAllInputGates();
			for (SingleInputGate gate : inputGates) {
				setupInputGate(gate);
			}
		}
	}
1238697
protected static void safeExecute(Runnable task) {
        try {
            task.run();
        } catch (Throwable t) {
            logger.warn("A task raised an exception. Task: {}", task, t);
        }
    }
1512
public int appendTask(long sourceHSId, TransactionInfoBaseMessage task) throws IOException {
        Preconditions.checkState(compiledSize == 0, "buffer is already compiled");

        final int msgSerializedSize = task.getSerializedSize();
        ensureCapacity(taskHeaderSize() + msgSerializedSize);

        ByteBuffer bb = m_container.b();
        bb.putInt(msgSerializedSize);
        bb.putLong(sourceHSId);

        int limit = bb.limit();
        bb.limit(bb.position() + msgSerializedSize);
        task.flattenToBuffer(bb.slice());
        bb.limit(limit);
        bb.position(bb.position() + msgSerializedSize);

        // Don't allow any further expansion to the underlying buffer
        if (bb.position() + taskHeaderSize() > DEFAULT_BUFFER_SIZE) {
            compile();
            return 0;
        } else {
            return DEFAULT_BUFFER_SIZE - (bb.position() + taskHeaderSize());
        }
    }
354585
public UBench addIntTask(String name, IntSupplier task) {
        return addIntTask(name, task, null);
    }