Skip to content

Commit

Permalink
fixing stak acumulating keen over time
Browse files Browse the repository at this point in the history
  • Loading branch information
mateusfreira committed Jan 30, 2018
1 parent 974cccf commit 923fb8d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion SimpleQueue.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ SimpleQueue.prototype.resume = function(){
SimpleQueue.prototype._checkStack = function(){
while(this._stack[this._finished]){
this._callback.apply(this, this._stack[this._finished]);
this._stack[this._finished] = null;
delete this._stack[this._finished];
this._finished += 1;
}
if(this._working === 0 && this._queue.length === 0 && this._done){
Expand Down
4 changes: 3 additions & 1 deletion tests/00-run.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,10 @@ function run(module){
throw Error("undexpected output, got: " + JSON.stringify(results));

var took = Date.now() - start;
if(took < module.takes) throw Error("didn't take enough time");
var stackSize = Object.keys(queue._stack).length;
if (took < module.takes) throw Error("didn't take enough time");
if(took > (module.takes + 500)) throw Error("wasted time");
if(stackSize !== 0) throw Error("stack size must be 0 at the end");

console.log("finished", module.name, "after (ms):", took);
}, module.concurrent);
Expand Down

0 comments on commit 923fb8d

Please sign in to comment.