Skip to content

Commit

Permalink
Refactor parallel execution logic in oJob
Browse files Browse the repository at this point in the history
  • Loading branch information
nmaguiar committed Oct 19, 2024
1 parent a9a0ef6 commit bd0f59d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
5 changes: 3 additions & 2 deletions js/owrap.oJob.js
Original file line number Diff line number Diff line change
Expand Up @@ -2264,9 +2264,10 @@ OpenWrap.oJob.prototype.runJob = function(aJob, provideArgs, aId, noAsync, rExec
var errors = [];
var single = false;
if (isDef(parent.__ojob.numThreads) && parent.__ojob.numThreads <= 1) single = true;
if (isDef(parent.__ojob.numThreads)) __cpucores = parent.__ojob.numThreads
if (isDef(aJob.typeArgs.single)) single = aJob.typeArgs.single;
if (!single) {
parallel4Array(args.__oJobRepeat, function(aValue) {
pForEach(args.__oJobRepeat, aValue => {
if (isUnDef(aValue.execid) && isUnDef(aValue.objId)) {
aValue.execid = args.execid;
aValue.objId = args.objId;
Expand Down Expand Up @@ -2305,7 +2306,7 @@ OpenWrap.oJob.prototype.runJob = function(aJob, provideArgs, aId, noAsync, rExec
} finally {
return true;
}
}, parent.__ojob.numThreads);
});
} else {
for(var aVi in args.__oJobRepeat) {
args.__oJobRepeat[aVi].execid = args.execid;
Expand Down
5 changes: 4 additions & 1 deletion tests/autoTestAll.oJob.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,10 @@
var testOJob = {
"jobs": [ {
"name": "a",
"exec": "sleep(50, true);__pm = args"
"typeArgs": {
"single": true
},
"exec": "sleep(50, true);__pm = merge(__pm, args)"
} ],
"todo": [ {
"name": "a",
Expand Down

0 comments on commit bd0f59d

Please sign in to comment.