668587dbf0bb85925640d9d90e90f991efde7cbf
[poolifier.git] / tests / worker-files / thread / testWorker.js
1 'use strict'
2 const { isMainThread } = require('worker_threads')
3 const { ThreadWorker, KillBehaviors } = require('../../../lib')
4 const TestUtils = require('../../test-utils')
5 const { WorkerFunctions } = require('../../test-types')
6
7 function test (data) {
8 data = data || {}
9 data.function = data.function || WorkerFunctions.jsonIntegerSerialization
10 const result = TestUtils.executeWorkerFunction(data)
11 if (result == null) {
12 return isMainThread
13 }
14 return result
15 }
16
17 module.exports = new ThreadWorker(test, {
18 maxInactiveTime: 500,
19 killBehavior: KillBehaviors.HARD
20 })