worker: avoid idle consumer blocking shared compute gate
This commit is contained in:
parent
4664806ba0
commit
51fbfa117d
1 changed files with 8 additions and 7 deletions
|
|
@ -1167,12 +1167,6 @@ async function main(): Promise<void> {
|
||||||
workerLabel: string;
|
workerLabel: string;
|
||||||
}): Promise<void> {
|
}): Promise<void> {
|
||||||
while (!stopping) {
|
while (!stopping) {
|
||||||
await jobGate.acquire();
|
|
||||||
if (stopping) {
|
|
||||||
jobGate.release();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
let msg: JsMsg | null = null;
|
let msg: JsMsg | null = null;
|
||||||
try {
|
try {
|
||||||
try {
|
try {
|
||||||
|
|
@ -1185,6 +1179,11 @@ async function main(): Promise<void> {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!msg) continue;
|
if (!msg) continue;
|
||||||
|
await jobGate.acquire();
|
||||||
|
if (stopping) {
|
||||||
|
jobGate.release();
|
||||||
|
return;
|
||||||
|
}
|
||||||
await processMessage({
|
await processMessage({
|
||||||
msg,
|
msg,
|
||||||
codec: input.codec,
|
codec: input.codec,
|
||||||
|
|
@ -1192,7 +1191,9 @@ async function main(): Promise<void> {
|
||||||
workerLabel: input.workerLabel,
|
workerLabel: input.workerLabel,
|
||||||
});
|
});
|
||||||
} finally {
|
} finally {
|
||||||
jobGate.release();
|
if (msg) {
|
||||||
|
jobGate.release();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue