mirror of
https://github.com/mozilla/pdf.js.git
synced 2026-06-27 18:45:48 +02:00
Change the "Terminate" worker-thread handler to an asynchronous function
This is a tiny bit shorter, which cannot hurt.
This commit is contained in:
parent
e8ab3cb335
commit
7f4e29ed22
@ -956,7 +956,7 @@ class WorkerMessageHandler {
|
|||||||
return pdfManager.cleanup(/* manuallyTriggered = */ true);
|
return pdfManager.cleanup(/* manuallyTriggered = */ true);
|
||||||
});
|
});
|
||||||
|
|
||||||
handler.on("Terminate", function (data) {
|
handler.on("Terminate", async function (data) {
|
||||||
terminated = true;
|
terminated = true;
|
||||||
|
|
||||||
const waitOn = [];
|
const waitOn = [];
|
||||||
@ -977,12 +977,11 @@ class WorkerMessageHandler {
|
|||||||
task.terminate();
|
task.terminate();
|
||||||
}
|
}
|
||||||
|
|
||||||
return Promise.all(waitOn).then(function () {
|
await Promise.all(waitOn);
|
||||||
// Notice that even if we destroying handler, resolved response promise
|
// Notice that even if we destroying handler, resolved response promise
|
||||||
// must be sent back.
|
// must be sent back.
|
||||||
handler.destroy();
|
handler.destroy();
|
||||||
handler = null;
|
handler = null;
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
handler.on("Ready", function (data) {
|
handler.on("Ready", function (data) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user