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