Merge dependabot/npm_and_yarn/examples/typescript/http-server-pool/fastify-worker_thr...
[poolifier.git] / tests / worker-files / thread / testWorker.js
index 3556da01f8051960125d833ec4b38e7196f6ad94..3945589f80cb088306c278ffcd5610526a615f6a 100644 (file)
@@ -1,15 +1,15 @@
 'use strict'
-const { ThreadWorker } = require('../../../lib/index')
-const { isMainThread } = require('worker_threads')
+const { ThreadWorker, KillBehaviors } = require('../../../lib')
+const { executeTaskFunction } = require('../../test-utils')
+const { TaskFunctions } = require('../../test-types')
 
 function test (data) {
-  for (let i = 0; i <= 50; i++) {
-    const o = {
-      a: i
-    }
-    JSON.stringify(o)
-  }
-  return isMainThread
+  data = data || {}
+  data.function = data.function || TaskFunctions.jsonIntegerSerialization
+  return executeTaskFunction(data)
 }
 
-module.exports = new ThreadWorker(test, { maxInactiveTime: 500 })
+module.exports = new ThreadWorker(test, {
+  killBehavior: KillBehaviors.HARD,
+  maxInactiveTime: 500
+})