UNPKG

693 BJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3exports.RunnerPool = void 0;
4const tslib_1 = require("tslib");
5const lock_1 = require("../lock");
6class RunnerPool {
7 constructor(limit) {
8 this.lock = new lock_1.Lock(limit);
9 }
10 run(task) {
11 return tslib_1.__awaiter(this, void 0, void 0, function* () {
12 yield this.lock.acquire(1);
13 try {
14 return yield task();
15 }
16 catch (e) {
17 throw e;
18 }
19 finally {
20 this.lock.release(1);
21 }
22 });
23 }
24}
25exports.RunnerPool = RunnerPool;
26//# sourceMappingURL=runner-pool.js.map
\No newline at end of file