Table of Contents

Class ReferenceCountedDictionaryPool<TKey, TValue, TArgument>

Namespace
HelixToolkit.SharpDX.Utilities
Assembly
HelixToolkit.SharpDX.dll

Base implementation for reference counted dictionary.

Object with same key will be returned by the pool or create an new object if key is not dictionary. And object reference count will be incremented by 1.

Set autoDispose = true in constructor if you want to automatically dispose the object once not being used from outside.
public abstract class ReferenceCountedDictionaryPool<TKey, TValue, TArgument> : DisposeObject, IDisposable where TKey : notnull where TValue : DisposeObject

Type Parameters

TKey
TValue
TArgument
Inheritance
ReferenceCountedDictionaryPool<TKey, TValue, TArgument>
Implements
Derived
Inherited Members

Constructors

ReferenceCountedDictionaryPool(bool)

protected ReferenceCountedDictionaryPool(bool autoDispose)

Parameters

autoDispose bool

Dispose object if no more exteranl references.

Properties

Count

public int Count { get; }

Property Value

int

DictionaryCount

public int DictionaryCount { get; }

Property Value

int

Items

protected IEnumerable<TValue> Items { get; }

Property Value

IEnumerable<TValue>

Methods

CanCreate(ref TKey, ref TArgument)

protected abstract bool CanCreate(ref TKey key, ref TArgument argument)

Parameters

key TKey
argument TArgument

Returns

bool

Clear()

protected void Clear()

OnCreate(ref TKey, ref TArgument)

protected abstract TValue? OnCreate(ref TKey key, ref TArgument argument)

Parameters

key TKey
argument TArgument

Returns

TValue

OnDispose(bool)

Disposes of object resources.

protected override void OnDispose(bool disposeManagedResources)

Parameters

disposeManagedResources bool

If true, managed resources should be disposed of in addition to unmanaged resources.

TryCreateOrGet(TKey, TArgument, out TValue?)

Try to create or get object from the pool. Reference is incremented before returning.

public bool TryCreateOrGet(TKey key, TArgument argument, out TValue? objOut)

Parameters

key TKey
argument TArgument
objOut TValue

Returns

bool

success or failed

TryDetach(TKey, out TValue?)

Try detach from the pool. The object will be removed from the pool and reference is not incremented before returning.

public bool TryDetach(TKey key, out TValue? objOut)

Parameters

key TKey
objOut TValue

Returns

bool

TryGet(TKey, out TValue?)

Try to get object by key. Reference will be incremented before returning.

public bool TryGet(TKey key, out TValue? objOut)

Parameters

key TKey
objOut TValue

Returns

bool