如果配置了生成器，则在请求之前调用生成器
@param task
356539
private void makeGenerators(Task task) {
        if (this.cookieGenerator != null) {
            if (!(this.cookieGenerator instanceof NoCookieGenerator)) {
                this.setCookie(this.cookieGenerator.get(task));
            }
        }
        if (this.headerGenerator != null) {
            if (!(this.headerGenerator instanceof NoHeaderGenerator)) {
                Map headers = this.headerGenerator.get(task);
                this.setHttpHeader(headers);
            }
        }
    }
1295519
public static void convert(Task task, Function<Throwable, RuntimeException> function) {
        try {
            task.run();
        } catch (Throwable e) {
            throw function.apply(e);
        }
    }
1142656
function(task, context, args) {
            // can used to default task
            if (!_.isFunction(task)) {
                args = task;
                task = null;
                context = null;
            }

            if (!_.isArray(args)) args = [args];

            var d = Q.defer();
            this.tasks.push({
                "task": task,
                "args": args || [],
                "context": context,
                "result": d
            });
            if (this.empty == true) {
                this.startNext();
            }
            return d.promise;
        }
725920
public TaskExecutor spawnExecutor(Task task) {
		final TaskExecutor executor = new TaskExecutor(this.scheduler, task);
		synchronized (this.executors) {
			this.executors.add(executor);
		}
		// 子线程是否为deamon线程取决于父线程，因此此处无需显示调用
		// executor.setDaemon(this.scheduler.daemon);
//		executor.start();
		this.scheduler.threadExecutor.execute(executor);
		return executor;
	}
807440
@GuardedBy("evictionLock")
    void runTasksInChain(Task task) {
        while (task != null) {
            Task current = task;
            task = task.getNext();
            current.setNext(null);
            current.run();
        }
    }
600911
@Override
    public void beforeExecute(Task task) {
        initializeBuildMetrics();
        long now = clock.getCurrentTime();
        Project project = task.getProject();
        ProjectMetrics projectMetrics = buildMetrics.getProjectProfile(project.getPath());
        projectMetrics.getTaskProfile(task.getPath()).setStart(now);
    }
1320409
public ResponseFromManager generateUpdateExecuteTask(ParallelTask task) {

        // add to map now; as can only pass final
        ParallelTaskManager.getInstance().addTaskToInProgressMap(
                task.getTaskId(), task);
        logger.info("Added task {} to the running inprogress map...",
                task.getTaskId());

        boolean useReplacementVarMap = false;
        boolean useReplacementVarMapNodeSpecific = false;
        Map<String, StrStrMap> replacementVarMapNodeSpecific = null;
        Map<String, String> replacementVarMap = null;

        ResponseFromManager batchResponseFromManager = null;

        switch (task.getRequestReplacementType()) {
        case UNIFORM_VAR_REPLACEMENT:
            useReplacementVarMap = true;
            useReplacementVarMapNodeSpecific = false;
            replacementVarMap = task.getReplacementVarMap();
            break;
        case TARGET_HOST_SPECIFIC_VAR_REPLACEMENT:
            useReplacementVarMap = false;
            useReplacementVarMapNodeSpecific = true;
            replacementVarMapNodeSpecific = task
                    .getReplacementVarMapNodeSpecific();
            break;
        case NO_REPLACEMENT:
            useReplacementVarMap = false;
            useReplacementVarMapNodeSpecific = false;
            break;
        default:
            logger.error("error request replacement type. default as no replacement");
        }// end switch

        // generate content in nodedata
        InternalDataProvider dp = InternalDataProvider.getInstance();
        dp.genNodeDataMap(task);

        VarReplacementProvider.getInstance()
                .updateRequestWithReplacement(task, useReplacementVarMap,
                        replacementVarMap, useReplacementVarMapNodeSpecific,
                        replacementVarMapNodeSpecific);

        batchResponseFromManager = 
                sendTaskToExecutionManager(task);

        removeTaskFromInProgressMap(task.getTaskId());
        logger.info(
                "Removed task {} from the running inprogress map... "
                        + ". This task should be garbage collected if there are no other pointers.",
                task.getTaskId());
        return batchResponseFromManager;

    }
1004507
private void writePredecessors(Task task)
   {
      List<Relation> relations = task.getPredecessors();
      for (Relation mpxj : relations)
      {
         RelationshipType xml = m_factory.createRelationshipType();
         m_project.getRelationship().add(xml);

         xml.setLag(getDuration(mpxj.getLag()));
         xml.setObjectId(Integer.valueOf(++m_relationshipObjectID));
         xml.setPredecessorActivityObjectId(mpxj.getTargetTask().getUniqueID());
         xml.setSuccessorActivityObjectId(mpxj.getSourceTask().getUniqueID());
         xml.setPredecessorProjectObjectId(PROJECT_OBJECT_ID);
         xml.setSuccessorProjectObjectId(PROJECT_OBJECT_ID);
         xml.setType(RELATION_TYPE_MAP.get(mpxj.getType()));
      }
   }
262349
public function create(Task $task): Task
    {
        $response = $this->client->post($this->prepareUrlForKey('add-task'), [], $task->jsonSerialize());
        $responseData = $response->getDecodedBody();

        return new Task($responseData);
    }
67487
public static void unqueue(Task task) {
    if(THREAD != null) {
      synchronized(THREAD) {
        THREAD.queue.remove(task);
      }
    }
  }
496073
public static void runIgnoringConstraintViolation(Runnable task)
    {
        try {
            task.run();
        }
        catch (RuntimeException e) {
            if (!sqlCodeStartsWith(e, "23")) {
                throw e;
            }
        }
    }
418064
public void register(Task task) {
        Optional.ofNullable(task)
                .filter(t -> t.getTask() != null)
                .filter(t -> StringUtils.hasText(t.getName()))
                .ifPresent(t -> checkTaskMap.put(t.getName(), t));
    }
27941
public static <T> Future<T> submit(Callable<T> task) {
		return executor.submit(task);
	}
254388
public void readTask(Task task) {
        Map<String, String> props = task.getProperties();
        setAccount(props.get(ACCOUNT_PROP));
        setStoreId(props.get(STORE_ID_PROP));
        setSpaceId(props.get(SPACE_ID_PROP));
        this.attempts = task.getAttempts();
    }
297712
@UnstableApi
    public final void executeAfterEventLoopIteration(Runnable task) {
        ObjectUtil.checkNotNull(task, "task");
        if (isShutdown()) {
            reject();
        }

        if (!tailTasks.offer(task)) {
            reject(task);
        }

        if (wakesUpForTask(task)) {
            wakeup(inEventLoop());
        }
    }
807431
public static <Result> TaskBuilder<Result> create(TaskCallback<Result> callback) {
        return new TaskBuilder<Result>().callback(callback);
    }
113206
private void readTask(String projectIdentifier, Map<String, Task> map, Document.Projects.Project.Task task)
   {
      Task parentTask = map.get(getParentOutlineNumber(task.getOutlineNumber()));
      Task mpxjTask = parentTask.addTask();

      TimeUnit units = task.getBaseDurationTimeUnit();

      mpxjTask.setCost(task.getActualCost());
      mpxjTask.setDuration(getDuration(units, task.getActualDuration()));
      mpxjTask.setFinish(task.getActualFinishDate());
      mpxjTask.setStart(task.getActualStartDate());
      mpxjTask.setBaselineDuration(getDuration(units, task.getBaseDuration()));
      mpxjTask.setBaselineFinish(task.getBaseFinishDate());
      mpxjTask.setBaselineCost(task.getBaselineCost());
      //      task.getBaselineFinishDate()
      //      task.getBaselineFinishTemplateOffset()
      //      task.getBaselineStartDate()
      //      task.getBaselineStartTemplateOffset()
      mpxjTask.setBaselineStart(task.getBaseStartDate());
      //      task.getCallouts()
      mpxjTask.setPercentageComplete(task.getComplete());
      mpxjTask.setDeadline(task.getDeadlineDate());
      //      task.getDeadlineTemplateOffset()
      //      task.getHyperlinks()
      //      task.getMarkerID()
      mpxjTask.setName(task.getName());
      mpxjTask.setNotes(task.getNote());
      mpxjTask.setPriority(task.getPriority());
      //      task.getRecalcBase1()
      //      task.getRecalcBase2()
      mpxjTask.setType(task.getSchedulingType());
      //      task.getStyleProject()
      //      task.getTemplateOffset()
      //      task.getValidatedByProject()

      if (task.isIsMilestone())
      {
         mpxjTask.setMilestone(true);
         mpxjTask.setDuration(Duration.getInstance(0, TimeUnit.HOURS));
         mpxjTask.setBaselineDuration(Duration.getInstance(0, TimeUnit.HOURS));
      }

      String taskIdentifier = projectIdentifier + "." + task.getID();
      m_taskIdMap.put(task.getID(), mpxjTask);
      mpxjTask.setGUID(UUID.nameUUIDFromBytes(taskIdentifier.getBytes()));

      map.put(task.getOutlineNumber(), mpxjTask);

      for (Document.Projects.Project.Task.ResourceAssignments.ResourceAssignment assignment : task.getResourceAssignments().getResourceAssignment())
      {
         readResourceAssignment(mpxjTask, assignment);
      }
   }