@beenotung/tslib
Version:
utils library in Typescript
21 lines (20 loc) • 463 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.RunnerPool = void 0;
const lock_1 = require("../lock");
class RunnerPool {
lock;
constructor(limit) {
this.lock = new lock_1.Lock(limit);
}
async run(task) {
await this.lock.acquire(1);
try {
return await task();
}
finally {
this.lock.release(1);
}
}
}
exports.RunnerPool = RunnerPool;