Commit | Line | Data |
---|---|---|
a449b585 | 1 | import { isPrimary } from 'node:cluster' |
8a970421 | 2 | import { ClusterWorker } from '../../lib/index.mjs' |
dbca3be9 JB |
3 | import { executeTaskFunction } from '../benchmarks-utils.mjs' |
4 | import { TaskFunctions } from '../benchmarks-types.mjs' | |
57df5469 | 5 | |
041dc05b | 6 | const taskFunction = data => { |
2d2e32c2 | 7 | data = data || {} |
dbca3be9 | 8 | data.function = data.function || TaskFunctions.jsonIntegerSerialization |
f1c674cd | 9 | data.debug = data.debug || false |
dbca3be9 | 10 | const res = executeTaskFunction(data) |
f1c674cd | 11 | data.debug === true && console.debug(`This is the main thread ${isPrimary}`) |
30b963d4 | 12 | return res |
106744f7 | 13 | } |
14 | ||
dbca3be9 | 15 | export default new ClusterWorker(taskFunction) |