repositories
/
poolifier.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
test: fix wrong async/await usage in describe()
[poolifier.git]
/
examples
/
yourWorker.js
diff --git
a/examples/yourWorker.js
b/examples/yourWorker.js
index 701aa8cf4d59cf15cd7623b0b09f8cbb0cef8928..b2df8d19093527e0ca67a24f9f84589ab1207050 100644
(file)
--- a/
examples/yourWorker.js
+++ b/
examples/yourWorker.js
@@
-1,20
+1,18
@@
'use strict'
'use strict'
-const { ThreadWorker } = require('../lib/workers')
+const { isMainThread } = require('worker_threads')
+const { ThreadWorker } = require('poolifier')
-function yourFunction (data) {
+const debug = false
+
+function yourFunction () {
for (let i = 0; i <= 1000; i++) {
const o = {
a: i
}
JSON.stringify(o)
}
for (let i = 0; i <= 1000; i++) {
const o = {
a: i
}
JSON.stringify(o)
}
-
// console.log
('This is the main thread ' + isMainThread)
+
debug === true && console.info
('This is the main thread ' + isMainThread)
return { ok: 1 }
}
return { ok: 1 }
}
-class MyWorker extends ThreadWorker {
- constructor () {
- super(yourFunction)
- }
-}
-module.exports = new MyWorker()
+module.exports = new ThreadWorker(yourFunction)