MCPcopy Create free account
hub / github.com/hashintel/hash / processQueue

Function processQueue

apps/plugin-browser/src/scripts/background/infer-entities.ts:71–93  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

69let numberOfOutstandingInputRequests = 0;
70
71const processQueue = async () => {
72 console.log({ numberOfOutstandingInputRequests });
73
74 if (numberOfOutstandingInputRequests >= maxConcurrentRequests) {
75 return;
76 }
77
78 const task = queue.shift();
79 if (!task) {
80 return;
81 }
82
83 numberOfOutstandingInputRequests++;
84 try {
85 await task();
86 } catch (err) {
87 console.error("Task failed:", err);
88 } finally {
89 numberOfOutstandingInputRequests--;
90 }
91
92 void processQueue();
93};
94
95const enqueueTask = (task: () => Promise<void>) => {
96 queue.push(task);

Callers 1

enqueueTaskFunction · 0.85

Calls 1

logMethod · 0.45

Tested by

no test coverage detected