Runner: Dev-Server bei Bedarf
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
4fffd8b218
commit
5b902519a9
4 files changed
+357
-9
No files matched your search
+16
-6
@@ -78,7 +78,7 @@ export function createJobs({ config, docker, fs: fsOver = {}, git, mem = readMem
|
||||
const queue = [];
|
||||
let active = false;
|
||||
let retry = false;
|
||||
const activeCaches = new Set();
|
||||
const activeCaches = new Map(); // Cache-Name ⇒ Anzahl Halter
|
||||
|
||||
// ---- Warteschlange mit genau einem aktiven Slot und Speicherwächter ----
|
||||
function pump() {
|
||||
@@ -144,11 +144,21 @@ export function createJobs({ config, docker, fs: fsOver = {}, git, mem = readMem
|
||||
return { workDir, detected };
|
||||
}
|
||||
|
||||
// Cache für die gesamte Laufzeit vor pruneCache schützen.
|
||||
async function holdCache(repo, fn) {
|
||||
// Cache vor pruneCache schützen; release() gibt ihn frei (idempotent). Zählend, mehrere Halter je Repo möglich.
|
||||
function retainCache(repo) {
|
||||
const n = cacheName(repo);
|
||||
activeCaches.add(n);
|
||||
try { return await fn(); } finally { activeCaches.delete(n); }
|
||||
activeCaches.set(n, (activeCaches.get(n) || 0) + 1);
|
||||
let done = false;
|
||||
return () => {
|
||||
if (done) return;
|
||||
done = true;
|
||||
const c = (activeCaches.get(n) || 1) - 1;
|
||||
if (c <= 0) activeCaches.delete(n); else activeCaches.set(n, c);
|
||||
};
|
||||
}
|
||||
async function holdCache(repo, fn) {
|
||||
const release = retainCache(repo);
|
||||
try { return await fn(); } finally { release(); }
|
||||
}
|
||||
|
||||
// ---- Atomare Veröffentlichung (R11) ----
|
||||
@@ -294,5 +304,5 @@ export function createJobs({ config, docker, fs: fsOver = {}, git, mem = readMem
|
||||
}
|
||||
}
|
||||
|
||||
return { submit, get, queueLength: () => queue.length + (active ? 1 : 0), prepareWorkspace, pruneCache };
|
||||
return { submit, get, queueLength: () => queue.length + (active ? 1 : 0), prepareWorkspace, retainCache, pruneCache };
|
||||
}
|
||||
Reference in new issue
Block a user