Blocks which complete synchronously have the completion de-nested. Big speed improvement, not quite sure why yet.
This commit is contained in:
parent
a3ed49a5ed
commit
b7549196da
20
src/Queue.js
20
src/Queue.js
|
@ -29,12 +29,20 @@ jasmine.Queue.prototype.isRunning = function() {
|
||||||
return this.running;
|
return this.running;
|
||||||
};
|
};
|
||||||
|
|
||||||
var nestLevel = 0;
|
jasmine.Queue.UNROLL = true;
|
||||||
|
|
||||||
jasmine.Queue.prototype.next_ = function() {
|
jasmine.Queue.prototype.next_ = function() {
|
||||||
var self = this;
|
var self = this;
|
||||||
if (self.index < self.blocks.length) {
|
if (self.index < self.blocks.length) {
|
||||||
self.blocks[self.index].execute(function () {
|
var calledSynchronously = true;
|
||||||
|
var completedSynchronously = false;
|
||||||
|
|
||||||
|
var onComplete = function () {
|
||||||
|
if (jasmine.Queue.UNROLL && calledSynchronously) {
|
||||||
|
completedSynchronously = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
self.offset = 0;
|
self.offset = 0;
|
||||||
self.index++;
|
self.index++;
|
||||||
|
|
||||||
|
@ -47,7 +55,13 @@ jasmine.Queue.prototype.next_ = function() {
|
||||||
} else {
|
} else {
|
||||||
self.next_();
|
self.next_();
|
||||||
}
|
}
|
||||||
});
|
};
|
||||||
|
self.blocks[self.index].execute(onComplete);
|
||||||
|
|
||||||
|
calledSynchronously = false;
|
||||||
|
if (completedSynchronously) {
|
||||||
|
onComplete();
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
self.running = false;
|
self.running = false;
|
||||||
if (self.onComplete) {
|
if (self.onComplete) {
|
||||||
|
|
Loading…
Reference in New Issue