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
TKeyTValueTArgument
- Inheritance
-
ReferenceCountedDictionaryPool<TKey, TValue, TArgument>
- Implements
- Derived
- Inherited Members
Constructors
ReferenceCountedDictionaryPool(bool)
protected ReferenceCountedDictionaryPool(bool autoDispose)
Parameters
autoDisposeboolDispose object if no more exteranl references.
Properties
Count
public int Count { get; }
Property Value
DictionaryCount
public int DictionaryCount { get; }
Property Value
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
keyTKeyargumentTArgument
Returns
Clear()
protected void Clear()
OnCreate(ref TKey, ref TArgument)
protected abstract TValue? OnCreate(ref TKey key, ref TArgument argument)
Parameters
keyTKeyargumentTArgument
Returns
- TValue
OnDispose(bool)
Disposes of object resources.
protected override void OnDispose(bool disposeManagedResources)
Parameters
disposeManagedResourcesboolIf 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
keyTKeyargumentTArgumentobjOutTValue
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
keyTKeyobjOutTValue
Returns
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
keyTKeyobjOutTValue