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