Commit | Line | Data |
---|---|---|
27006a3d | 1 | 'use strict' |
a449b585 | 2 | const { isMainThread } = require('node:worker_threads') |
65d7a1c9 | 3 | const { ThreadWorker } = require('poolifier') |
fd7ebd49 JB |
4 | |
5 | const debug = false | |
27006a3d | 6 | |
7a6a0a96 | 7 | function yourFunction () { |
106744f7 | 8 | for (let i = 0; i <= 1000; i++) { |
9 | const o = { | |
10 | a: i | |
11 | } | |
12 | JSON.stringify(o) | |
13 | } | |
1c132fec | 14 | debug === true && console.info(`This is the main thread ${isMainThread}`) |
106744f7 | 15 | return { ok: 1 } |
16 | } | |
17 | ||
1f9a5a44 | 18 | module.exports = new ThreadWorker(yourFunction) |