Greedify the queue loading strategy

This commit is contained in:
Alessandro Isaacs
2015-07-10 12:03:01 -07:00
parent 5149889bd2
commit 2142b538ac
2 changed files with 12 additions and 22 deletions

View File

@@ -45,6 +45,7 @@ describe('ol.TileQueue', function() {
var maxLoading = numTiles / 2;
// and nothing is loading
expect(q1.getTilesLoading()).to.equal(0);
expect(q2.getTilesLoading()).to.equal(0);
@@ -52,32 +53,20 @@ describe('ol.TileQueue', function() {
q1.loadMoreTiles(maxLoading, maxLoading);
q2.loadMoreTiles(maxLoading, maxLoading);
// since tiles can only load once, we expect one queue to load them
expect(q1.getTilesLoading()).to.equal(maxLoading);
expect(q2.getTilesLoading()).to.equal(0);
// however, both queues will be reduced
expect(q1.getCount()).to.equal(numTiles - maxLoading);
expect(q2.getCount()).to.equal(numTiles - maxLoading);
// ask both to load more
q1.loadMoreTiles(maxLoading, maxLoading);
q2.loadMoreTiles(maxLoading, maxLoading);
// now the second queue will be empty
expect(q1.getCount()).to.equal(numTiles - maxLoading);
expect(q2.getCount()).to.equal(0);
// after the first is saturated, the second should start loading
// both tiles will be loading the max
expect(q1.getTilesLoading()).to.equal(maxLoading);
expect(q2.getTilesLoading()).to.equal(maxLoading);
// the second queue will be empty now
expect(q1.getCount()).to.equal(numTiles - maxLoading);
expect(q2.getCount()).to.equal(0);
// let all tiles load
setTimeout(function() {
expect(q1.getTilesLoading()).to.equal(0);
expect(q2.getTilesLoading()).to.equal(0);
// load again, which will clear the first queue
// ask both to load, this should clear q1
q1.loadMoreTiles(maxLoading, maxLoading);
q2.loadMoreTiles(maxLoading, maxLoading);