allen-cell-animated / volume-viewer

https://allen-cell-animated.github.io/volume-viewer/
Other
90 stars 7 forks source link

Allow new loads to pick up on old requests in progress #154

Closed frasercl closed 5 months ago

frasercl commented 10 months ago

Use Case

With RequestQueue added to the zarr load path, if OMEZarrLoader.loadVolumeData is called and then called again before chunk requests generated by the first call can complete, we should be able to cancel the requests made by the previous call. However, it is possible that the new loads want the same chunks! We should be able to transfer ownership of in-progress requests to the new load, rather than send lots of different requests for the same data.

Solution

Enable either RequestQueue or a new wrapper class to pick cancelled requests back up if they were already in progress. Make promises returned by this queue unique to a single request and a single subscriber, and reject only the promise associated with a single subscriber without trying to halt a request in progress. Use this new behavior to implement the behavior described above.