docs: document availableParallelism() usage
[poolifier.git] / examples / multiFunctionExample.js
index 055f143fdafae8ee1eb82e65f161d0f69f6b2e4e..829ba93d4c59e852f872a47c6d5dbaa9dc4c5597 100644 (file)
@@ -1,8 +1,13 @@
-const { FixedThreadPool } = require('poolifier')
-const pool = new FixedThreadPool(15, './multiFunctionWorker.js', {
-  errorHandler: e => console.error(e),
-  onlineHandler: () => console.info('worker is online')
-})
+const { FixedThreadPool, availableParallelism } = require('poolifier')
+
+const pool = new FixedThreadPool(
+  availableParallelism(),
+  './multiFunctionWorker.js',
+  {
+    errorHandler: e => console.error(e),
+    onlineHandler: () => console.info('worker is online')
+  }
+)
 
 pool
   .execute({ text: 'hello' }, 'fn0')