Commit | Line | Data |
---|---|---|
a449b585 | 1 | import { isMainThread } from 'node:worker_threads' |
8a970421 | 2 | import { ThreadWorker } from '../../lib/index.mjs' |
dbca3be9 JB |
3 | import { executeTaskFunction } from '../benchmarks-utils.mjs' |
4 | import { TaskFunctions } from '../benchmarks-types.mjs' | |
8a970421 | 5 | |
041dc05b | 6 | const taskFunction = data => { |
8a970421 | 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 JB |
11 | data.debug === true && |
12 | console.debug(`This is the main thread ${isMainThread}`) | |
30b963d4 | 13 | return res |
8a970421 JB |
14 | } |
15 | ||
dbca3be9 | 16 | export default new ThreadWorker(taskFunction) |