pool.emitter.on(PoolEvents.busy, () => console.info('Pool is busy'))
// or a dynamic worker-threads pool
-const pool = new DynamicThreadPool(availableParallelism() / 2, availableParallelism(), './yourWorker.js', {
+const pool = new DynamicThreadPool(Math.floor(availableParallelism() / 2), availableParallelism(), './yourWorker.js', {
errorHandler: e => console.error(e),
onlineHandler: () => console.info('worker is online')
})
switch (workerType) {
case WorkerTypes.thread:
return new DynamicThreadPool(
- poolSize / 2,
+ Math.floor(poolSize / 2),
poolSize * 3,
'./benchmarks/internal/thread-worker.mjs',
poolOptions
)
case WorkerTypes.cluster:
return new DynamicClusterPool(
- poolSize / 2,
+ Math.floor(poolSize / 2),
poolSize * 3,
'./benchmarks/internal/cluster-worker.mjs',
poolOptions
} = require('poolifier')
const pool = new DynamicThreadPool(
- availableParallelism() / 2,
+ Math.floor(availableParallelism() / 2),
availableParallelism(),
'./yourWorker.js',
{
)
export const dynamicPool = new DynamicThreadPool<MyData, Promise<MyResponse>>(
- availableParallelism() / 2,
+ Math.floor(availableParallelism() / 2),
availableParallelism(),
join(__dirname, 'worker.js'),
{