@polyfill-io-aot/builder
Version:
This is the builder module for polyfill-io-aot.
34 lines • 1.02 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const Bluebird = require("bluebird");
const noop = require("lodash/noop");
const wp = require("workerpool");
const Executor_1 = require("./Executor");
/** @internal */
class PoolExecutor extends Executor_1.Executor {
_initPool(path) {
this._terminate().catch(noop);
this._pool = wp.pool(path, {
maxWorkers: this.conf.processes,
minWorkers: this.conf.processes
});
}
_terminate() {
if (this._pool) {
return this._wrap(this._pool.terminate()).then(noop);
}
return Bluebird.resolve();
}
/**
* The worker pool promises are a tad buggy
* @param input Worker pool promise
* @returns Bluebird-wrapped promise
*/
_wrap(input) {
return new Bluebird((resolve, reject) => {
input.then(resolve).catch(reject);
});
}
}
exports.PoolExecutor = PoolExecutor;
//# sourceMappingURL=PoolExecutor.js.map