Better implementation for async loop control
This commit is contained in:
1 parent
7d30ffd176
commit
12aa43c379
4 files changed
+94
-85
No files matched your search
+8
-7
@@ -275,16 +275,17 @@ function run(script, globals, timestamp, deviceData, extensionsCache, startRevis
|
||||
let extCache = sandbox.extensionsCache;
|
||||
let args = arguments;
|
||||
|
||||
let counter = 1;
|
||||
let counter = 3;
|
||||
for (let key in sandbox.extensions) {
|
||||
++ counter;
|
||||
counter += 2;
|
||||
extensions.run(sandbox.extensions[key], function(err, fault, res) {
|
||||
if ((err || fault) && counter > 0) {
|
||||
counter = 0;
|
||||
return callback(err, fault);
|
||||
if (err || fault) {
|
||||
if (counter & 1)
|
||||
callback(err, fault);
|
||||
return counter = 0;
|
||||
}
|
||||
extCache[key] = res;
|
||||
if (-- counter === 0)
|
||||
if ((counter -= 2) === 1)
|
||||
if (status === 2)
|
||||
return run.apply(null, args);
|
||||
else
|
||||
@@ -292,7 +293,7 @@ function run(script, globals, timestamp, deviceData, extensionsCache, startRevis
|
||||
});
|
||||
}
|
||||
|
||||
if (-- counter === 0)
|
||||
if ((counter -= 2) === 1)
|
||||
if (status === 2)
|
||||
return run.apply(null, args);
|
||||
else
|
||||
|
||||
Reference in new issue
Block a user