Invoke all the prerequisites of a task in parallel.
550362
def invoke_prerequisites_concurrently(task_args, invocation_chain)# :nodoc:
      futures = prerequisite_tasks.map do |p|
        prereq_args = task_args.new_scope(p.arg_names)
        application.thread_pool.future(p) do |r|
          r.invoke_with_call_chain(prereq_args, invocation_chain)
        end
      end
      # Iterate in reverse to improve performance related to thread waiting and switching
      futures.reverse_each(&:value)
    end
1073431
def invoke_with_call_chain(task_args, invocation_chain) # :nodoc:
      new_chain = InvocationChain.append(self, invocation_chain)
      @lock.synchronize do
        if application.options.trace
          puts "** Invoke #{name} #{format_trace_flags}"
        end
        return if @already_invoked
        @already_invoked = true
        invoke_prerequisites(task_args, new_chain)
        execute(task_args) if needed?
      end
    end
361792
public ParallelTaskBuilder preparePing() {
        reinitIfClosed();
        ParallelTaskBuilder cb = new ParallelTaskBuilder();
        cb.setProtocol(RequestProtocol.PING);
        return cb;
    }
402190
def run_parallel(workflow, n_threads):
    
    scheduler = Scheduler()
    threaded_worker = Queue() >> thread_pool(
        *repeat(worker, n_threads))

    return scheduler.run(threaded_worker, get_workflow(workflow))
765653
function main () {
  var taskList = _(arguments).toArray().flatten(true).value()
  gulp.task('default', taskList)
  return this
}
1060772
function invokeTask(taskName)
{
    const tc = TASKS.globals.globalTaskCollection;
    const t = tc.getByName(taskName);
    if (t === undefined)
    {
        YERROR.raiseError(`task ${taskName} not found`);
    }

    TASKS.invokeTask(tc, t);    
}
273247
def _invoke(task, args):
	''''''
	kwargs = task.defaults.copy()
	if task.kwargs:
		temp_kwargs, args = getopt.getopt(args, '', task.kwargs)
		temp_kwargs = _opts_to_dict(*temp_kwargs)
		kwargs.update(temp_kwargs)

	if task.args:
		for arg in task.args:
			if not len(args):
				abort(LOCALE['error_wrong_args'], task, len(task.args))
			kwargs.update({arg: args[0]})
			args = args[1:]

	if task.consume:
		task(*args, **kwargs)
		return []
	else:
		task(**kwargs)
		return args
761858
def execute_task(self, task, parent_result):
        
        task.before_run(parent_result)
        context = task.create_context(self.message_queue)
        pending_result = self.pool.apply_async(execute_task_async, (task.func, task.id, context))
        self.pending_results.append(pending_result)
584751
void runTasks(Task[] tasks, int maxTaskIndex) {
        for (int i = 0; i <= maxTaskIndex; i++) {
            runTasksInChain(tasks[i]);
            tasks[i] = null;
        }
    }
1327179
@SuppressWarnings("unchecked")
    public void parallel(C context, final Outcome<C> outcome, final Function<C>... functions) {
        final C finalContext = context != null ? context : (C) EMPTY_CONTEXT;
        final CountingControl ctrl = new CountingControl(finalContext, functions);
        progress.reset(functions.length);

        Scheduler.get().scheduleIncremental(new Scheduler.RepeatingCommand() {
            @Override
            public boolean execute() {
                if (ctrl.isAborted() || ctrl.allFinished()) {
                    // schedule deferred so that 'return false' executes first!
                    Scheduler.get().scheduleDeferred(new Scheduler.ScheduledCommand() {
                        @Override
                        @SuppressWarnings("unchecked")
                        public void execute() {
                            if (ctrl.isAborted()) {
                                progress.finish();
                                outcome.onFailure(finalContext);
                            } else {
                                progress.finish();
                                outcome.onSuccess(finalContext);
                            }

                        }
                    });
                    return false;
                } else {
                    // one after the other until all are active
                    ctrl.next();
                    return true;
                }
            }
        });
    }
367230
def make_ready_all(self):
        
        T = self.tm.trace
        if T: T.write(self.trace_message('Task.make_ready_all()', self.node))

        self.out_of_date = self.targets[:]
        for t in self.targets:
            t.disambiguate().set_state(NODE_EXECUTING)
            for s in t.side_effects:
                # add disambiguate here to mirror the call on targets above
                s.disambiguate().set_state(NODE_EXECUTING)
627252
def _run(cls):
        """"""
        if cls._thread:
            with cls._lock:
                # First run: execute each task once to get it started
                for task in cls.tasks:
                    cls._execute_task(task)
                cls.tasks.sort()
                cls._last_execution = time.time()

        while cls._thread:
            with cls._lock:
                if cls.tasks:
                    for task in cls.tasks:
                        if task.next_execution - cls._last_execution < 0.5:
                            cls._execute_task(task)
                        else:
                            break
                    cls.tasks.sort()
                    cls._last_execution = time.time()
                    cls._sleep_delay = cls.tasks[0].next_execution - cls._last_execution

                else:
                    cls._sleep_delay = 1

                sleep_delay = max(0.1, cls._sleep_delay)

            # Don't hold cls._lock while sleeping, sleep delay should be 1 second when no tasks are present
            time.sleep(sleep_delay)
1192417
function loopTask(arrayResults) {
      arrayResults = Array.prototype.map.call(arrayResults, wrap);
      return parallel(arrayResults).call(this);
    }
1127945
def create(parallel):
    
    queue = {k: v for k, v in parallel.items() if k in ["queue", "cores_per_job", "mem"]}
    yield queue
145619
function parallel (promiseFunctions, limit = Infinity, silenceErrors = false) {
  const contraMethod = (tasks, callback) => concurrent(tasks, limit, callback)
  return generatePromise(promiseFunctions, contraMethod, silenceErrors)
}
894135
function parallel(inst, elems, argv, event, fin, _postSequence) {
    var total = elems.length;
    var complete = 0;
    function check(err, list) {
        if (total === ++complete) {
            if (!_isFunc(list)) return _postSequence(list, fin);
            return fin(err, list);
        }
    }
    for (var i = 0; i < total; i++) {
        if (_isList(elems[i])) {
            var after = edit(inst, elems, i, argv, event, check);
            branch(inst, elems[i], argv, event, after);
        }
        else {
            check(null, elems);
        }
    }
}
169500
def invoke(*args)
      task_args = TaskArguments.new(arg_names, args)
      invoke_with_call_chain(task_args, InvocationChain::EMPTY)
    end