1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | exports.RunnerPool = void 0;
|
4 | const tslib_1 = require("tslib");
|
5 | const lock_1 = require("../lock");
|
6 | class 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 | }
|
25 | exports.RunnerPool = RunnerPool;
|
26 |
|
\ | No newline at end of file |