Search Results for

    Show / Hide Table of Contents

    Class DrawableCache

    Caches drawable objects per (feature, style) combination. Thread-safe: drawables are created on a background thread and read on the UI thread. Uses strict iteration-based eviction: anything not stamped with the current iteration is removed on Cleanup(long).

    Inheritance
    object
    DrawableCache
    Implements
    IDrawableCache
    IDisposable
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: Mapsui.Rendering
    Assembly: Mapsui.dll
    Syntax
    public sealed class DrawableCache : IDrawableCache, IDisposable

    Methods

    | Edit this page View Source

    Cleanup(long)

    Evicts stale cache entries. The exact strategy depends on the implementation:

    • DrawableCache: removes everything not stamped with currentIteration.
    • TileDrawableCache: keeps a number of extra tiles and removes the oldest by iteration.
    Declaration
    public void Cleanup(long currentIteration)
    Parameters
    Type Name Description
    long currentIteration
    Remarks

    Strict cleanup: removes and disposes every entry whose iteration is not currentIteration. This ensures that features no longer in the viewport are cleaned up immediately.

    | Edit this page View Source

    Clear()

    Clears all cached entries and disposes them.

    Declaration
    public void Clear()
    | Edit this page View Source

    Dispose()

    Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

    Declaration
    public void Dispose()
    | Edit this page View Source

    Get(DrawableCacheKey, long)

    Gets the drawable for a (feature, style) combination, or null if not cached. Stamps the entry with iteration so that Cleanup(long) knows the entry is still in use.

    Declaration
    public IDrawable? Get(DrawableCacheKey key, long iteration)
    Parameters
    Type Name Description
    DrawableCacheKey key

    The composite key of feature and style GenerationIds.

    long iteration

    The current render iteration.

    Returns
    Type Description
    IDrawable
    | Edit this page View Source

    ReleaseReservation(DrawableCacheKey)

    Releases a reservation previously acquired via TryReserve(DrawableCacheKey). Call this in a finally block after creation completes (success or failure).

    Declaration
    public void ReleaseReservation(DrawableCacheKey key)
    Parameters
    Type Name Description
    DrawableCacheKey key

    The composite key to release.

    | Edit this page View Source

    Set(DrawableCacheKey, IDrawable, long)

    Stores a drawable for a (feature, style) combination. GenerationIds are immutable — each combination is only ever set once. If the entry already exists it is not replaced. The entry is stamped with iteration.

    Declaration
    public void Set(DrawableCacheKey key, IDrawable drawable, long iteration)
    Parameters
    Type Name Description
    DrawableCacheKey key

    The composite key of feature and style GenerationIds.

    IDrawable drawable

    The drawable to cache.

    long iteration

    The current render iteration.

    | Edit this page View Source

    TryReserve(DrawableCacheKey)

    Attempts to reserve a key for creation. If the key is already reserved by another thread (creation in progress) or already exists in the cache, returns false. Use this before creating an expensive drawable to avoid duplicate work.

    Declaration
    public bool TryReserve(DrawableCacheKey key)
    Parameters
    Type Name Description
    DrawableCacheKey key

    The composite key of feature and style GenerationIds.

    Returns
    Type Description
    bool

    True if the reservation was successful; false if already reserved or cached.

    Implements

    IDrawableCache
    IDisposable

    Extension Methods

    DisposableExtension.DisposeIfDisposable(object?)
    • Edit this page
    • View Source
    In this article
    Back to top Generated by DocFX