think-cluster
Advanced tools
Comparing version 1.5.3 to 1.5.4
@@ -11,3 +11,4 @@ const cluster = require('cluster'); | ||
let taskId = 1; | ||
// task counter | ||
let count = 0; | ||
@@ -48,7 +49,7 @@ /** | ||
if (message.mapReturn) { | ||
const map = mapPromise.get(message.action); | ||
const map = mapPromise.get(`${message.action}_${message.taskId}`); | ||
map.get(worker).resolve(message.data); | ||
} else { | ||
const map = new Map(); | ||
mapPromise.set(message.action, map); | ||
mapPromise.set(`${message.action}_${message.taskId}`, map); | ||
const promises = workers.map(worker => { | ||
@@ -62,3 +63,3 @@ worker.send(message); | ||
message.data = data; | ||
message.action = `${message.action}_ret`; | ||
message.action = `${message.action}_${message.taskId}_ret`; | ||
worker.send(message); | ||
@@ -110,5 +111,8 @@ }); | ||
const defer = helper.defer(); | ||
count = count % Number.MAX_SAFE_INTEGER + 1; | ||
const taskId = count + '' + process.pid; | ||
process.send({ | ||
act: MESSENGER, | ||
action, | ||
taskId, | ||
mapData, | ||
@@ -118,3 +122,3 @@ map: true, | ||
}); | ||
this.once(`${action}_ret`, data => { | ||
this.once(`${action}_${taskId}_ret`, data => { | ||
defer.resolve(data); | ||
@@ -121,0 +125,0 @@ mapPromise.delete(action); |
{ | ||
"name": "think-cluster", | ||
"description": "Cluster manage for ThinkJS", | ||
"version": "1.5.3", | ||
"version": "1.5.4", | ||
"author": { | ||
@@ -6,0 +6,0 @@ "name": "welefen", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
50869
1805