MCPcopy Create free account
hub / github.com/adcontextprotocol/adcp / processWithConcurrency

Method processWithConcurrency

server/src/crawler.ts:1062–1080  ·  view source on GitHub ↗
(
    items: T[],
    concurrency: number,
    fn: (item: T) => Promise<R>
  )

Source from the content-addressed store, hash-verified

1060 }
1061
1062 private async processWithConcurrency<T, R>(
1063 items: T[],
1064 concurrency: number,
1065 fn: (item: T) => Promise<R>
1066 ): Promise<R[]> {
1067 const results: R[] = [];
1068 let index = 0;
1069
1070 async function worker() {
1071 while (index < items.length) {
1072 const i = index++;
1073 results[i] = await fn(items[i]);
1074 }
1075 }
1076
1077 const workers = Array.from({ length: Math.min(concurrency, items.length) }, () => worker());
1078 await Promise.all(workers);
1079 return results;
1080 }
1081}

Callers 1

crawlCatalogDomainsMethod · 0.95

Calls 1

workerFunction · 0.85

Tested by

no test coverage detected