Table of Contents

Class TileDiskStoreLifecycle

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
object
TileDiskStoreLifecycle

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

cacheDirectory string

Folder for tiles.dat and tiles.idx.

cacheSettings TileCacheSettings

Disk-cache cap and compaction.

storeFactory Func<string, TileCacheSettings, ITilePersistentStore>

Consumer store opener; null uses the shipped PackedTileStore.

getStore Func<ITilePersistentStore>

Reads the caller's store field.

setStore Action<ITilePersistentStore>

Writes the caller's store field.

Properties

CacheDirectory

public string CacheDirectory { get; }

Property Value

string

DiskCacheCompactionsRun

public int DiskCacheCompactionsRun { get; }

Property Value

int

DiskCacheDisabled

public bool DiskCacheDisabled { get; }

Property Value

bool

DiskCacheDroppedWrites

public int DiskCacheDroppedWrites { get; }

Property Value

int

DiskCacheIoFailures

public int DiskCacheIoFailures { get; }

Property Value

int

DiskCacheMaxBytes

public long DiskCacheMaxBytes { get; }

Property Value

long

DiskCacheShrinking

public bool DiskCacheShrinking { get; }

Property Value

bool

Store

The disk store this lifecycle currently holds; frame-path reads/writes go through this.

public ITilePersistentStore Store { get; }

Property Value

ITilePersistentStore

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

bool

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

now double

Current 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

maxDataBytes long

New 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

now double

Current 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.