| 5513 | |
| 5514 | // -- builds ----------------------------------------------------------------- |
| 5515 | const buildOf = (fetcher: Fetcher): Build => { |
| 5516 | let build = (fetcher as { readonly [BuildTypeId]?: Build })[BuildTypeId] |
| 5517 | if (build === undefined) { |
| 5518 | build = fakeBuilds.get(fetcher) |
| 5519 | if (build === undefined) { |
| 5520 | build = { |
| 5521 | fetcher, |
| 5522 | closed: false, |
| 5523 | listeners: new Set(), |
| 5524 | fibers: new Set() |
| 5525 | } |
| 5526 | fakeBuilds.set(fetcher, build) |
| 5527 | } |
| 5528 | return build |
| 5529 | } |
| 5530 | if (!build.closed && !attached.has(build)) { |
| 5531 | attached.add(build) |
| 5532 | build.listeners.add(buildClosed) |
| 5533 | } |
| 5534 | return build |
| 5535 | } |
| 5536 | /** The build the cache uses when it asks itself: the earliest live watcher's, then a waiter's. */ |
| 5537 | const survivingBuild = (entry: Entry): Build | undefined => { |
| 5538 | for (const watcher of entry.watchers) { |