MCPcopy
hub / github.com/Deepractice/PromptX / push

Method push

packages/runtime/src/internal/AsyncQueue.ts:44–56  ·  view source on GitHub ↗

* Push an item to the queue * * If there's a waiting consumer, deliver directly (no buffering). * Otherwise, buffer the item for later consumption.

(item: T)

Source from the content-addressed store, hash-verified

42 * Otherwise, buffer the item for later consumption.
43 */
44 push(item: T): void {
45 if (this.closed) return;
46
47 // Key: Check if there's a waiting consumer FIRST
48 if (this.waiting.length > 0) {
49 // Deliver directly to waiting consumer (no race condition)
50 const resolve = this.waiting.shift()!;
51 resolve({ done: false, value: item });
52 } else {
53 // No waiting consumer, buffer the item
54 this.buffer.push(item);
55 }
56 }
57
58 /**
59 * Close the queue

Callers 15

createLoggerFunction · 0.80
parseRequestBodyFunction · 0.80
listDirectoryFunction · 0.80
getProjectsByMcpIdMethod · 0.80
getProjectInstancesMethod · 0.80
scanProjectResourcesMethod · 0.80
getCommandDetailsMethod · 0.80
registerAreaMethod · 0.80
registerLayerMethod · 0.80
renderAreasMethod · 0.80

Calls

no outgoing calls

Tested by 4

stepFunction · 0.64
stepFunction · 0.64
stepFunction · 0.64
stepFunction · 0.64