UNPKG

@beenotung/tslib

Version:
26 lines 693 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.RunnerPool = void 0; const tslib_1 = require("tslib"); const lock_1 = require("../lock"); class RunnerPool { constructor(limit) { this.lock = new lock_1.Lock(limit); } run(task) { return tslib_1.__awaiter(this, void 0, void 0, function* () { yield this.lock.acquire(1); try { return yield task(); } catch (e) { throw e; } finally { this.lock.release(1); } }); } } exports.RunnerPool = RunnerPool; //# sourceMappingURL=runner-pool.js.map