• Articles
  • API Documentation
Search Results for

    Show / Hide Table of Contents
    • SixLabors.ImageSharp.Web
      • FormattedImage
      • FormatUtilities
      • ImageCacheMetadata
      • ImageMetadata
    • SixLabors.ImageSharp.Web.Caching
      • CacheHash
      • ICacheHash
      • IImageCache
      • PhysicalFileSystemCache
      • PhysicalFileSystemCacheOptions
    • SixLabors.ImageSharp.Web.Commands
      • CommandParser
      • DictionaryExtensions
      • IRequestParser
      • PresetOnlyQueryCollectionRequestParser
      • PresetOnlyQueryCollectionRequestParserOptions
      • QueryCollectionRequestParser
    • SixLabors.ImageSharp.Web.Commands.Converters
      • ICommandConverter
      • ICommandConverter<T>
    • SixLabors.ImageSharp.Web.DependencyInjection
      • ApplicationBuilderExtensions
      • IImageSharpBuilder
      • ImageSharpBuilderExtensions
      • ImageSharpConfiguration
      • ServiceCollectionExtensions
    • SixLabors.ImageSharp.Web.Middleware
      • ConcurrentDictionaryExtensions
      • ImageCommandContext
      • ImageProcessingContext
      • ImageSharpMiddleware
      • ImageSharpMiddlewareOptions
    • SixLabors.ImageSharp.Web.Processors
      • BackgroundColorWebProcessor
      • FormatWebProcessor
      • IImageWebProcessor
      • JpegQualityWebProcessor
      • ResizeWebProcessor
    • SixLabors.ImageSharp.Web.Providers
      • IImageProvider
      • PhysicalFileSystemProvider
      • ProcessingBehavior
    • SixLabors.ImageSharp.Web.Resolvers
      • IImageCacheResolver
      • IImageResolver
      • PhysicalFileSystemCacheResolver
      • PhysicalFileSystemResolver
    • SixLabors.ImageSharp.Web.Synchronization
      • AsyncKeyLock<TKey>
      • AsyncKeyReaderWriterLock<TKey>
      • AsyncLock
      • AsyncReaderWriterLock
      • RefCountedConcurrentDictionary<TKey, TValue>

    Class RefCountedConcurrentDictionary<TKey, TValue>

    Represents a thread-safe collection of reference-counted key/value pairs that can be accessed by multiple threads concurrently. Values that don't yet exist are automatically created using a caller supplied value factory method, and when their final refcount is released they are removed from the dictionary.

    Inheritance
    Object
    RefCountedConcurrentDictionary<TKey, TValue>
    Inherited Members
    Object.Equals(Object)
    Object.Equals(Object, Object)
    Object.GetHashCode()
    Object.GetType()
    Object.MemberwiseClone()
    Object.ReferenceEquals(Object, Object)
    Object.ToString()
    Namespace: SixLabors.ImageSharp.Web.Synchronization
    Assembly: SixLabors.ImageSharp.Web.dll
    Syntax
    public class RefCountedConcurrentDictionary<TKey, TValue>
        where TValue : class
    Type Parameters
    Name Description
    TKey

    The type of the key.

    TValue

    The value for the dictionary.

    Constructors

    | Improve this Doc View Source

    RefCountedConcurrentDictionary(IEqualityComparer<TKey>, Func<TKey, TValue>, Action<TValue>)

    Initializes a new instance of the RefCountedConcurrentDictionary<TKey, TValue> class that is empty, has the default concurrency level and capacity,, and uses the specified IEqualityComparer<T>.

    Declaration
    public RefCountedConcurrentDictionary(IEqualityComparer<TKey> comparer, Func<TKey, TValue> valueFactory, Action<TValue> valueReleaser)
    Parameters
    Type Name Description
    IEqualityComparer<TKey> comparer

    The IEqualityComparer<T> implementation to use when comparing keys.

    Func<TKey, TValue> valueFactory

    Factory method that generates a new TValue for a given TKey.

    Action<TValue> valueReleaser

    Optional callback that is used to cleanup TValues after their final ref count is released.

    | Improve this Doc View Source

    RefCountedConcurrentDictionary(Func<TKey, TValue>, Action<TValue>)

    Initializes a new instance of the RefCountedConcurrentDictionary<TKey, TValue> class that is empty, has the default concurrency level, has the default initial capacity, and uses the default comparer for the key type.

    Declaration
    public RefCountedConcurrentDictionary(Func<TKey, TValue> valueFactory, Action<TValue> valueReleaser = null)
    Parameters
    Type Name Description
    Func<TKey, TValue> valueFactory

    Factory method that generates a new TValue for a given TKey.

    Action<TValue> valueReleaser

    Optional callback that is used to cleanup TValues after their final ref count is released.

    | Improve this Doc View Source

    RefCountedConcurrentDictionary(Int32, Int32, IEqualityComparer<TKey>, Func<TKey, TValue>, Action<TValue>)

    Initializes a new instance of the RefCountedConcurrentDictionary<TKey, TValue> class that is empty, has the specified concurrency level, has the specified initial capacity, and uses the specified IEqualityComparer<T>.

    Declaration
    public RefCountedConcurrentDictionary(int concurrencyLevel, int capacity, IEqualityComparer<TKey> comparer, Func<TKey, TValue> valueFactory, Action<TValue> valueReleaser)
    Parameters
    Type Name Description
    Int32 concurrencyLevel

    The estimated number of threads that will access the RefCountedConcurrentDictionary<TKey, TValue> concurrently

    Int32 capacity

    The initial number of elements that the RefCountedConcurrentDictionary<TKey, TValue> can contain.

    IEqualityComparer<TKey> comparer

    The IEqualityComparer<T> implementation to use when comparing keys.

    Func<TKey, TValue> valueFactory

    Factory method that generates a new TValue for a given TKey.

    Action<TValue> valueReleaser

    Optional callback that is used to cleanup TValues after their final ref count is released.

    | Improve this Doc View Source

    RefCountedConcurrentDictionary(Int32, Int32, Func<TKey, TValue>, Action<TValue>)

    Initializes a new instance of the RefCountedConcurrentDictionary<TKey, TValue> class that is empty, has the specified concurrency level and capacity, and uses the default comparer for the key type.

    Declaration
    public RefCountedConcurrentDictionary(int concurrencyLevel, int capacity, Func<TKey, TValue> valueFactory, Action<TValue> valueReleaser = null)
    Parameters
    Type Name Description
    Int32 concurrencyLevel

    The estimated number of threads that will access the RefCountedConcurrentDictionary<TKey, TValue> concurrently

    Int32 capacity

    The initial number of elements that the RefCountedConcurrentDictionary<TKey, TValue> can contain.

    Func<TKey, TValue> valueFactory

    Factory method that generates a new TValue for a given TKey.

    Action<TValue> valueReleaser

    Optional callback that is used to cleanup TValues after their final ref count is released.

    Methods

    | Improve this Doc View Source

    Get(TKey)

    Obtains a reference to the value corresponding to the specified key. If no such value exists in the dictionary, then a new value is generated using the value factory method supplied in the constructor. To prevent leaks, this reference MUST be released via Release(TKey).

    Declaration
    public TValue Get(TKey key)
    Parameters
    Type Name Description
    TKey key

    The key of the element to add ref.

    Returns
    Type Description
    TValue

    The referenced object.

    | Improve this Doc View Source

    Release(TKey)

    Releases a reference to the value corresponding to the specified key. If this reference was the last remaining reference to the value, then the value is removed from the dictionary, and the optional value releaser callback is invoked.

    Declaration
    public void Release(TKey key)
    Parameters
    Type Name Description
    TKey key

    THe key of the element to release.

    • Improve this Doc
    • View Source
    In This Article
    Back to top Generated by DocFX