Fix CI job condition
[poolifier.git] / examples / yourWorker.js
index 701aa8cf4d59cf15cd7623b0b09f8cbb0cef8928..3e59f3465db2269fbb4ed2827f3c048c6010a8b8 100644 (file)
@@ -1,5 +1,8 @@
 'use strict'
-const { ThreadWorker } = require('../lib/workers')
+const { ThreadWorker } = require('poolifier')
+const { isMainThread } = require('worker_threads')
+
+const debug = false
 
 function yourFunction (data) {
   for (let i = 0; i <= 1000; i++) {
@@ -8,13 +11,8 @@ function yourFunction (data) {
     }
     JSON.stringify(o)
   }
-  // console.log('This is the main thread ' + isMainThread)
+  debug === true && console.log('This is the main thread ' + isMainThread)
   return { ok: 1 }
 }
 
-class MyWorker extends ThreadWorker {
-  constructor () {
-    super(yourFunction)
-  }
-}
-module.exports = new MyWorker()
+module.exports = new ThreadWorker(yourFunction)