mirror of
https://github.com/dillonkearns/elm-pages-v3-beta.git
synced 2025-01-03 17:31:58 +03:00
Use setImmediate to enqueue tasks sequentially so the work is delegated to multiple threads.
This commit is contained in:
parent
951d57a12a
commit
eef18eee93
@ -377,7 +377,12 @@ async function start(options) {
|
||||
readyThreads.forEach((readyThread) => {
|
||||
const startTask = threadReadyQueue.shift();
|
||||
if (startTask) {
|
||||
startTask(readyThread);
|
||||
// if we don't use setImmediate here, the remaining work will be done sequentially by a single worker
|
||||
// using setImmediate delegates a ready thread to each pending task until it runs out of ready workers
|
||||
// so the delegation is done sequentially, and the actual work is then executed
|
||||
setImmediate(() => {
|
||||
startTask(readyThread);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user