Merge pull request #544 from kim-company/fix-imageloader

Fix the jobLimit of the imageLoader
This commit is contained in:
Ian Gilman 2014-12-29 11:48:20 -08:00
commit b141a22c87
3 changed files with 10 additions and 6 deletions

View File

@ -46,7 +46,7 @@ module.exports = function(grunt) {
"src/referencestrip.js",
"src/displayrectangle.js",
"src/spring.js",
"src/imageLoader.js",
"src/imageloader.js",
"src/tile.js",
"src/overlay.js",
"src/drawer.js",

View File

@ -94,14 +94,16 @@ ImageJob.prototype = {
* @memberof OpenSeadragon
* @classdesc Handles downloading of a set of images using asynchronous queue pattern.
* You generally won't have to interact with the ImageLoader directly.
* @param {Object} options - Options for this ImageLoader.
* @param {Number} [options.jobLimit] - The number of concurrent image requests. See imageLoaderLimit in {@link OpenSeadragon.Options} for details.
*/
$.ImageLoader = function() {
$.ImageLoader = function( options ) {
$.extend( true, this, {
jobLimit: $.DEFAULT_SETTINGS.imageLoaderLimit,
jobQueue: [],
jobsInProgress: 0
});
}, options );
};
@ -131,7 +133,7 @@ $.ImageLoader.prototype = /** @lends OpenSeadragon.ImageLoader.prototype */{
this.jobsInProgress++;
}
else {
this.jobQueue.push( newJob );
this.jobQueue.push( newJob );
}
},
@ -160,10 +162,10 @@ function completeJob( loader, job, callback ) {
if ( (!loader.jobLimit || loader.jobsInProgress < loader.jobLimit) && loader.jobQueue.length > 0) {
nextJob = loader.jobQueue.shift();
nextJob.start();
loader.jobsInProgress++;
}
callback( job.image );
}
}( OpenSeadragon ));

View File

@ -436,7 +436,9 @@ $.Viewer = function( options ) {
this.viewport.setHomeBounds(this.world.getHomeBounds(), this.world.getContentFactor());
// Create the image loader
this.imageLoader = new $.ImageLoader();
this.imageLoader = new $.ImageLoader({
jobLimit: this.imageLoaderLimit
});
// Create the tile cache
this.tileCache = new $.TileCache({