imglib / imglib2-cache

Cache interfaces and java.lang.ref based implementation.
Other
6 stars 4 forks source link

Support growing numPriorities in BlockingFetchQueues #18

Open tpietzsch opened 1 year ago

tpietzsch commented 1 year ago

BlockingFetchQueues is used to prioritize cell loading requests. For multi-resolution images in BigDataViewer, cell requests are usually enqueued with a discrete priority level derived from the resolution level, such that low-resolution data is loaded before high-resolution data. Every resolution level corresponds to a priority level.

Currently, the number of priority levels is defined in the constructor and remains fixed. Instead, BlockingFetchQueues should support to grow the number of priority levels after construction. This would be helpful, for example for SharedQueue, where many multi-res images may be using the same queue, and the maximum number of resolution levels cannot be pre-determined when the queue is created.

Concretely: Add a new method void ensureNumPriorities(int numPriorities) which makes sure that (at least) numPriorities priority levels are available Reallocate queues[] if it needs to grow. The method should be protected by the same lock as take() and put().