repositories
/
poolifier.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
test: add queue tests
[poolifier.git]
/
tests
/
worker-files
/
thread
/
testWorker.js
diff --git
a/tests/worker-files/thread/testWorker.js
b/tests/worker-files/thread/testWorker.js
index 3556da01f8051960125d833ec4b38e7196f6ad94..668587dbf0bb85925640d9d90e90f991efde7cbf 100644
(file)
--- a/
tests/worker-files/thread/testWorker.js
+++ b/
tests/worker-files/thread/testWorker.js
@@
-1,15
+1,20
@@
'use strict'
'use strict'
-const { ThreadWorker } = require('../../../lib/index')
const { isMainThread } = require('worker_threads')
const { isMainThread } = require('worker_threads')
+const { ThreadWorker, KillBehaviors } = require('../../../lib')
+const TestUtils = require('../../test-utils')
+const { WorkerFunctions } = require('../../test-types')
function test (data) {
function test (data) {
- for (let i = 0; i <= 50; i++) {
- const o = {
- a: i
- }
- JSON.stringify(o)
+ data = data || {}
+ data.function = data.function || WorkerFunctions.jsonIntegerSerialization
+ const result = TestUtils.executeWorkerFunction(data)
+ if (result == null) {
+ return isMainThread
}
}
- return
isMainThread
+ return
result
}
}
-module.exports = new ThreadWorker(test, { maxInactiveTime: 500 })
+module.exports = new ThreadWorker(test, {
+ maxInactiveTime: 500,
+ killBehavior: KillBehaviors.HARD
+})