Commit | Line | Data |
---|---|---|
57df5469 | 1 | 'use strict' |
23ff945a | 2 | const { isMainThread } = require('worker_threads') |
cdace0e5 JB |
3 | const { ThreadWorker } = require('../../lib') |
4 | const { executeWorkerFunction } = require('../benchmarks-utils') | |
5 | const { WorkerFunctions } = require('../benchmarks-types') | |
57df5469 | 6 | |
23ff945a JB |
7 | const debug = false |
8 | ||
106744f7 | 9 | function yourFunction (data) { |
2d2e32c2 JB |
10 | data = data || {} |
11 | data.function = data.function || WorkerFunctions.jsonIntegerSerialization | |
12 | executeWorkerFunction(data) | |
23ff945a | 13 | debug === true && console.debug('This is the main thread ' + isMainThread) |
106744f7 | 14 | return { ok: 1 } |
15 | } | |
16 | ||
1f9a5a44 | 17 | module.exports = new ThreadWorker(yourFunction) |