in src/dicomImageSequencer.js [135:159]
checkFetchQueue(onImageReady) {
// Calculate how many requests can be sent out
const availableRequests =
this.maxSimultaneousRequests - this.currentSimultaneousRequests;
const requestsRemaining = this.fetchQueue.length;
// Send out as many requests as available
if (availableRequests > 0 && requestsRemaining > 0) {
for (let i = 0; i < Math.min(availableRequests, requestsRemaining); i++) {
const imageURL = this.fetchQueue.shift();
this.currentSimultaneousRequests++;
// Load image with cornerstone
cornerstone.loadImage(imageURL).then((image) => {
// Store loaded image and check the instance queue
this.loadedImages[image.imageId] = image;
this.checkInstanceQueue(onImageReady);
// Make a new request available and check the fetch queue
this.currentSimultaneousRequests--;
this.checkFetchQueue(onImageReady);
});
}
}
}