MCPcopy Create free account
hub / github.com/buct2012dbl/Dorchestrator / execute

Method execute

coding-agent/src/core/executor.ts:27–55  ·  view source on GitHub ↗
(tasks: Task<T>[])

Source from the content-addressed store, hash-verified

25 }
26
27 async execute<T>(tasks: Task<T>[]): Promise<TaskResult<T>[]> {
28 // Add tasks to queue
29 this.queue.push(...tasks);
30
31 // Sort by priority (higher first)
32 this.queue.sort((a, b) => b.priority - a.priority);
33
34 // Execute tasks
35 const activeTasks = new Set<Promise<void>>();
36
37 while (this.queue.length > 0 || this.running > 0) {
38 while (this.running < this.maxConcurrent && this.queue.length > 0) {
39 const task = this.queue.shift()!;
40 let taskPromise!: Promise<void>;
41 taskPromise = this.executeTask(task).finally(() => {
42 activeTasks.delete(taskPromise);
43 });
44 activeTasks.add(taskPromise);
45 }
46
47 // Wait for at least one task to complete
48 if (activeTasks.size > 0) {
49 await Promise.race(activeTasks);
50 }
51 }
52
53 // Return results in original order
54 return tasks.map(task => this.results.get(task.id)!);
55 }
56
57 private async executeTask<T>(task: Task<T>): Promise<void> {
58 this.running++;

Callers

nothing calls this directly

Calls 3

executeTaskMethod · 0.95
deleteMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected