Skip to main content

Module cache

Module cache 

Source
Expand description

Shared, immutable, byte-bounded decoded-tile cache with single-flight loading.

  • Values are Arc<[f32]>; readers never mutate them.
  • A key is decoded at most once while resident: concurrent requests wait for the loader.
  • Eviction is least-recently-used among unpinned entries (no outside Arc holder), so the resident byte total, including in-use and loading tiles, never exceeds the budget. If the budget cannot be met because everything is pinned, the request fails with a budget error rather than exceeding it. The session validates threads * max_tiles_per_item * tile_bytes <= budget, which makes that failure unreachable for planned work.
  • The budget covers decoded resident slots only. Decoder transients of a concurrent miss (terrio window buffer, tiff chunk buffer, compressed bytes, chunk offset tables and the Arc<[f32]> copy) are outside it; peak_concurrent_loads lets callers estimate them.
  • Unwind safety: a loader that returns an error or panics releases its Loading slot and its bytes, counts a load error and wakes every waiter (drop guard). A panic is caught and returned as a typed MapError::Terrain; waiters then retry the load themselves.

Structs§

CacheStats
TileCache

Type Aliases§

Key