repositories
/
poolifier.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Add UTs for WorkerChoiceStrategyContext
[poolifier.git]
/
examples
/
yourWorker.js
diff --git
a/examples/yourWorker.js
b/examples/yourWorker.js
index 5036d5746be21fe1b48310b7909f0f6f0fb057b3..4597f6485b0073f01854c8285213c5e27ed689fb 100644
(file)
--- a/
examples/yourWorker.js
+++ b/
examples/yourWorker.js
@@
-1,19
+1,15
@@
'use strict'
'use strict'
-const { ThreadWorker } = require('
../lib/workers
')
+const { ThreadWorker } = require('
poolifier
')
-class MyWorker extends ThreadWorker {
- constructor () {
- super((data) => {
- for (let i = 0; i <= 10000; i++) {
- const o = {
- a: i
- }
- JSON.stringify(o)
- }
- // console.log('This is the main thread ' + isMainThread)
- return { ok: 1 }
- })
+function yourFunction (data) {
+ for (let i = 0; i <= 1000; i++) {
+ const o = {
+ a: i
+ }
+ JSON.stringify(o)
}
}
+ // console.log('This is the main thread ' + isMainThread)
+ return { ok: 1 }
}
}
-module.exports = new
MyWorker(
)
+module.exports = new
ThreadWorker(yourFunction
)