public trackOpenTask()

in src/orchestrations/TaskOrchestrationExecutor.ts [456:492]


    public trackOpenTask(task: NoOpTask | DFTask): void {
        // The open tasks and open events objects only track singular tasks, not compound ones.
        // Therefore, for a compound task, we recurse down to its inner sub-tasks add
        // record all singular tasks.
        if (task instanceof CompoundTask) {
            for (const child of task.children) {
                this.trackOpenTask(child);
            }
        } else {
            if (task.id === false) {
                // The task needs to be given an ID and then stored.
                task.id = this.sequenceNumber++;
                this.openTasks[task.id] = task;
            } else if (task.actionObj instanceof WaitForExternalEventAction) {
                // The ID of a  `WaitForExternalEvent` task is the name of
                // the external event it awaits. Given that multiple `WaitForExternalEvent`
                // tasks can await the same event name at once, we need
                // to store these tasks as a list.

                // Obtain the current list of tasks for this external event name.
                // If there's no such list, we initialize it.
                const candidateEventList: TaskBase[] | undefined = this.openEvents[task.id];
                const eventList = candidateEventList !== undefined ? candidateEventList : [];

                eventList.push(task);
                this.openEvents[task.id] = eventList;
            }

            // If the task's ID can be found in deferred tasks, then we have already processed
            // the history event that contains the result for this task. Therefore, we immediately
            // assign this task's result so that the user-code may proceed executing.
            if (this.deferredTasks.hasOwnProperty(task.id)) {
                const taskUpdateAction = this.deferredTasks[task.id];
                taskUpdateAction();
            }
        }
    }