refactor: cleanup examples
[poolifier.git] / examples / multiFunctionExample.js
index 055f143fdafae8ee1eb82e65f161d0f69f6b2e4e..27a503256b776d163b29ad7a64a0a8d425ebf6c1 100644 (file)
@@ -1,8 +1,14 @@
-const { FixedThreadPool } = require('poolifier')
-const pool = new FixedThreadPool(15, './multiFunctionWorker.js', {
-  errorHandler: e => console.error(e),
-  onlineHandler: () => console.info('worker is online')
-})
+'use strict'
+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')