GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — claude-code-source-code/src/bridge/capacityWake.ts at main · francisk/claude-code-source-code Expand file tree/ Copy pathcapacityWake.tsMore file actions 56 lines (50 loc) · 1.8 KB / Copy pathcapacityWake.tsFile metadata and controls56 lines (50 loc) · 1.8 KB 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 /** * Shared capacity-wake primitive for bridge poll loops. * * Both replBridge.ts and bridgeMain.ts need to sleep while "at capacity" * but wake early when either (a) the outer loop signal aborts (shutdown), * or (b) capacity frees up (session done / transport lost). This module * encapsulates the mutable wake-controller + two-signal merger that both * poll loops previously duplicated byte-for-byte. */ export type CapacitySignal = { signal: AbortSignal; cleanup: () => void } export type CapacityWake = { /** * Create a signal that aborts when either the outer loop signal or the * capacity-wake controller fires. Returns the merged signal and a cleanup * function that removes listeners when the sleep resolves normally * (without abort). */ signal(): CapacitySignal /** * Abort the current at-capacity sleep and arm a fresh controller so the * poll loop immediately re-checks for new work. */ wake(): void } export function createCapacityWake(outerSignal: AbortSignal): CapacityWake { let wakeController = new AbortController() function wake(): void { wakeController.abort() wakeController = new AbortController() } function signal(): CapacitySignal { const merged = new AbortController() const abort = (): void => merged.abort() if (outerSignal.aborted || wakeController.signal.aborted) { merged.abort() return { signal: merged.signal, cleanup: () => {} } } outerSignal.addEventListener('abort', abort, { once: true }) const capSig = wakeController.signal capSig.addEventListener('abort', abort, { once: true }) return { signal: merged.signal, cleanup: () => { outerSignal.removeEventListener('abort', abort) capSig.removeEventListener('abort', abort) }, } } return { signal, wake } } |
| You are visitor 01402792 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |