MCPcopy Create free account
hub / github.com/ColmapView/Colmapview.github.io / queueLoad

Function queueLoad

src/hooks/useAsyncImageCache.ts:192–212  ·  view source on GitHub ↗

* Queue a load with concurrency limiting.

(imageFile: File, cacheKey: string)

Source from the content-addressed store, hash-verified

190 * Queue a load with concurrency limiting.
191 */
192 function queueLoad(imageFile: File, cacheKey: string): Promise<T | null> {
193 const generation = state.cacheGeneration;
194
195 return new Promise((resolve) => {
196 const doLoad = () => {
197 if (generation !== state.cacheGeneration) {
198 // clear() was called - it already reset activeLoads, don't decrement
199 resolve(null);
200 return;
201 }
202 loadFromFile(imageFile, cacheKey, generation).then(resolve);
203 };
204
205 if (state.activeLoads < MAX_CONCURRENT_LOADS) {
206 state.activeLoads++;
207 doLoad();
208 } else {
209 state.pendingQueue.push(() => doLoad());
210 }
211 });
212 }
213
214 return {
215 /**

Callers 3

loadFunction · 0.85
prefetchAsyncImagesFunction · 0.85

Calls 1

doLoadFunction · 0.85

Tested by

no test coverage detected