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