mirror of
https://github.com/openseadragon/openseadragon.git
synced 2025-03-27 10:33:52 +03:00
Merge pull request #544 from kim-company/fix-imageloader
Fix the jobLimit of the imageLoader
This commit is contained in:
commit
b141a22c87
@ -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",
|
||||
|
@ -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 ));
|
||||
|
@ -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({
|
||||
|
Loading…
x
Reference in New Issue
Block a user