Class TileDiskStoreLifecycle
- Namespace
- LansMap.Map.TilePipeline
Owns a TileStreamer's disk-store instance across its whole lifecycle: initial open (degrading rather than throwing), the reopen retry after a locked file, detach/reattach for pool parking, and the throttled health reporting a consumer would otherwise have no signal for. TileStreamer keeps every public member unchanged and forwards to this type; frame-path store reads/writes still go through the store this type currently holds.
public sealed class TileDiskStoreLifecycle
- Inheritance
-
objectTileDiskStoreLifecycle
Remarks
Public rather than internal because this project ships no InternalsVisibleTo seam for its test assembly (Unity has been known to drop a standalone AssemblyInfo.cs with no diagnostic) - EditMode tests reflect into this type by name for two allocation-gate self-checks (ReportHealth(double), the private reopen-retry method). Not part of the supported public API surface; TileStreamer's own public members are the supported entry points.
Constructors
TileDiskStoreLifecycle(string, TileCacheSettings, Func<string, TileCacheSettings, ITilePersistentStore>, Func<ITilePersistentStore>, Action<ITilePersistentStore>)
Opens (or degrades) the disk store for cacheDirectory.
public TileDiskStoreLifecycle(string cacheDirectory, TileCacheSettings cacheSettings, Func<string, TileCacheSettings, ITilePersistentStore> storeFactory, Func<ITilePersistentStore> getStore, Action<ITilePersistentStore> setStore)
Parameters
cacheDirectorystringFolder for tiles.dat and tiles.idx.
cacheSettingsTileCacheSettingsDisk-cache cap and compaction.
storeFactoryFunc<string, TileCacheSettings, ITilePersistentStore>Consumer store opener; null uses the shipped PackedTileStore.
getStoreFunc<ITilePersistentStore>Reads the caller's store field.
setStoreAction<ITilePersistentStore>Writes the caller's store field.
Properties
CacheDirectory
public string CacheDirectory { get; }
Property Value
DiskCacheCompactionsRun
public int DiskCacheCompactionsRun { get; }
Property Value
DiskCacheDisabled
public bool DiskCacheDisabled { get; }
Property Value
DiskCacheDroppedWrites
public int DiskCacheDroppedWrites { get; }
Property Value
DiskCacheIoFailures
public int DiskCacheIoFailures { get; }
Property Value
DiskCacheMaxBytes
public long DiskCacheMaxBytes { get; }
Property Value
DiskCacheShrinking
public bool DiskCacheShrinking { get; }
Property Value
Store
The disk store this lifecycle currently holds; frame-path reads/writes go through this.
public ITilePersistentStore Store { get; }
Property Value
Methods
ClearDiskCache()
Wipes the packed disk files; GPU residency is unchanged.
public void ClearDiskCache()
CompactDiskCacheNow()
Rewrites the packed file now to reclaim orphaned blobs, and returns true if the file shrank.
public bool CompactDiskCacheNow()
Returns
DetachDiskStore()
Releases this streamer's hold on its disk store, for a pool that is about to park this streamer rather than dispose it.
public void DetachDiskStore()
Remarks
A parked streamer that keeps holding tiles.dat/tiles.idx
(FileShare.None) blocks any other streamer built for the
same cache directory from ever opening it - the disk cache dies
for the rest of the session instead of just this one streamer's
idle stretch. This disposes the real store (which flushes before
closing), swaps in a degraded one (misses and drops, like any
other open failure), and re-arms the same reopen retry
TryAttachDiskStore already runs, restarting its backoff
from now. A later Checkout (Tick(MapViewTransform, double) via the
pending reopen flag) reattaches a real store without anyone else
having to have released one first.
Dispose()
Releases the disk store.
public void Dispose()
ReportHealth(double)
Reports disk-cache degradation and death, throttled and latched. Call once per Tick.
public void ReportHealth(double now)
Parameters
nowdoubleCurrent time in seconds.
SetDiskCacheMaxBytes(long)
Changes the live disk cap in bytes; growth is immediate, shrink evicts across following ticks.
public void SetDiskCacheMaxBytes(long maxDataBytes)
Parameters
maxDataByteslongNew live-data cap in bytes.
StepShrinkDrain()
Drains a pending shrink by one store-bounded step, if a shrink is in progress.
public void StepShrinkDrain()
TickReopenIfPending(double)
Retries the scheduled disk-store reopen if one is pending and due. Call at the very top of Tick, before any frame code asks the store a question - the swap must never happen mid-frame, after something this tick has already read an answer from the store being replaced.
public void TickReopenIfPending(double now)
Parameters
nowdoubleCurrent time in seconds.
TryReattachDiskStoreNow()
Attempts to reopen the real disk store right now, without waiting for the scheduled reopen backoff. Call on every Checkout.
public void TryReattachDiskStoreNow()
Remarks
A pooled streamer already released its own hold on the file via DetachDiskStore(), so the scheduled retry's 1 s first delay would otherwise drop every disk write and hit for no reason on the common reuse path. Does not count against the three-attempt budget; on failure the scheduled retry runs unaffected.