| import { QueueParent } from "@/Queue/QueueParent"; |
| import { IJobInfo } from "@/Queue/QueueTypes"; |
| import { runWorker } from "@/Core/WebWorkers/RunWorker"; |
|
|
| |
| |
| |
| export class ReduceQueue extends QueueParent { |
| |
| |
| |
| |
| |
| |
| |
| public async runJobBatch( |
| inputBatch: IJobInfo[], |
| procs: number |
| ): Promise<IJobInfo[]> { |
| const outputs: IJobInfo[] = []; |
| for (const jobInfo of inputBatch) { |
| |
| |
| |
| outputs.push(await this._runJob(jobInfo)); |
| } |
|
|
| return outputs; |
| } |
|
|
| |
| |
| |
| |
| |
| |
| private async _runJob(jobInfo: IJobInfo): Promise<IJobInfo> { |
| |
| jobInfo.input.treeNode = undefined; |
|
|
| return runWorker( |
| new Worker(new URL("./Reduce.worker", import.meta.url)), |
| jobInfo, |
| true |
| ) |
| .then((response) => { |
| |
| jobInfo.output = response.output; |
| return jobInfo; |
| }) |
| .catch((err) => { |
| throw err; |
| }); |
| } |
| } |
|
|