WorkerPool based on worker_threads that allows executing synchronous functions asynchronously using Workers stored in pool
Usage
const WorkerPool = ;const hardFunction = { const somelib = ; //require should be inside the function //do some calculations return `Result of calculations #`;};const pool = 4;const emptyPool = ;emptyPoolallowSpawn = true; //set this flag if you want to allow spawning additional forksconst task1 = pool;const task2 = emptyPool;task1promise;task2promise;
Warning
NodeJS with version below 11.7.0 is unsupported but it may still work with flag --experimental-worker