UNPKG

601 BJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3exports.TaskPool = void 0;
4const task_queue_1 = require("./task-queue");
5class TaskPool extends task_queue_1.TaskQueue {
6 constructor(concurrentSize = 1) {
7 super();
8 this.concurrentSize = concurrentSize;
9 this.ps = new Array(concurrentSize).fill('').map(() => new task_queue_1.TaskQueue());
10 this.i = 0;
11 }
12 runTask(f) {
13 this.i = (this.i + 1) % this.ps.length;
14 return this.ps[this.i].runTask(f);
15 }
16}
17exports.TaskPool = TaskPool;
18//# sourceMappingURL=task-pool.js.map
\No newline at end of file