f88cf076268cbff5f600a44eebc9bad7c64b0687
[poolifier.git] / benchmarks / internal / thread-worker.mjs
1 import { isMainThread } from 'worker_threads'
2 import { ThreadWorker } from '../../lib/index.mjs'
3 import { executeTaskFunction } from '../benchmarks-utils.mjs'
4 import { TaskFunctions } from '../benchmarks-types.mjs'
5
6 const debug = false
7
8 const taskFunction = (data) => {
9 data = data || {}
10 data.function = data.function || TaskFunctions.jsonIntegerSerialization
11 const res = executeTaskFunction(data)
12 debug === true && console.debug(`This is the main thread ${isMainThread}`)
13 return res
14 }
15
16 export default new ThreadWorker(taskFunction)