MCPcopy Create free account
hub / github.com/anomalyco/opencode / drain

Function drain

packages/app/src/context/global-sync/queue.ts:50–73  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

48 }
49
50 async function drain() {
51 if (running) return
52 running = true
53 try {
54 while (true) {
55 if (input.paused()) return
56 if (root) {
57 root = false
58 await input.bootstrap()
59 await tick()
60 continue
61 }
62 const dirs = take(2)
63 if (dirs.length === 0) return
64 await Promise.all(dirs.map((dir) => input.bootstrapInstance(dir)))
65 await tick()
66 }
67 } finally {
68 running = false
69 // oxlint-disable-next-line no-unsafe-finally -- intentional: early return skips schedule() when paused
70 if (input.paused()) return
71 if (root || queued.size) schedule()
72 }
73 }
74
75 return {
76 push,

Callers 1

scheduleFunction · 0.70

Calls 4

tickFunction · 0.70
takeFunction · 0.70
scheduleFunction · 0.70
allMethod · 0.45

Tested by

no test coverage detected