Fix batch task running in case of zero count.
This commit is contained in:
parent
1cdf592c4f
commit
67a249f528
@ -21,7 +21,10 @@ OV.TaskRunner = class
|
||||
|
||||
RunBatch (count, batchCount, callbacks)
|
||||
{
|
||||
const stepCount = parseInt ((count - 1) / batchCount, 10) + 1;
|
||||
let stepCount = 0;
|
||||
if (count > 0) {
|
||||
stepCount = parseInt ((count - 1) / batchCount, 10) + 1;
|
||||
}
|
||||
this.Run (stepCount, {
|
||||
runTask : function (index, ready) {
|
||||
const firstIndex = index * batchCount;
|
||||
|
||||
@ -44,5 +44,20 @@ describe ('Task Runner', function () {
|
||||
done ();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
it ('Run task batched zero times', function (done) {
|
||||
var tr = new OV.TaskRunner ();
|
||||
var indices = [];
|
||||
tr.RunBatch (0, 3, {
|
||||
runTask : function (firstIndex, lastIndex, ready) {
|
||||
indices.push ([firstIndex, lastIndex]);
|
||||
ready ();
|
||||
},
|
||||
onReady : function () {
|
||||
assert.deepStrictEqual (indices, []);
|
||||
done ();
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Loading…
Reference in New Issue
Block a user