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;
|
||||
}): Promise<void> {
|
||||
while (!stopping) {
|
||||
await jobGate.acquire();
|
||||
if (stopping) {
|
||||
jobGate.release();
|
||||
return;
|
||||
}
|
||||
|
||||
let msg: JsMsg | null = null;
|
||||
try {
|
||||
try {
|
||||
|
|
@ -1185,6 +1179,11 @@ async function main(): Promise<void> {
|
|||
}
|
||||
|
||||
if (!msg) continue;
|
||||
await jobGate.acquire();
|
||||
if (stopping) {
|
||||
jobGate.release();
|
||||
return;
|
||||
}
|
||||
await processMessage({
|
||||
msg,
|
||||
codec: input.codec,
|
||||
|
|
@ -1192,7 +1191,9 @@ async function main(): Promise<void> {
|
|||
workerLabel: input.workerLabel,
|
||||
});
|
||||
} finally {
|
||||
jobGate.release();
|
||||
if (msg) {
|
||||
jobGate.release();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue