Class KeyedPool<TKey, TItem>
A pool of items that can be registered against a given key.
Inherited Members
Namespace: Microsoft.ML.Probabilistic.Collections
Assembly: Microsoft.ML.Probabilistic.dll
Syntax
public class KeyedPool<TKey, TItem>
Type Parameters
Name | Description |
---|---|
TKey | The type of a key. |
TItem | The type of an item. |
Constructors
KeyedPool(Func<TItem>)
Initializes a new instance of the KeyedPool<TKey, TItem> class.
Declaration
public KeyedPool(Func<TItem> itemFactory)
Parameters
Type | Name | Description |
---|---|---|
Func<TItem> | itemFactory | A factory for producing new items. |
Methods
Acquire(TKey)
Returns an item registered against a given key. If there are no items registered against that key, returns an item registered against any key. If there are no registered items at all, returns a new one.
Declaration
public TItem Acquire(TKey desiredKey)
Parameters
Type | Name | Description |
---|---|---|
TKey | desiredKey | The desired key. |
Returns
Type | Description |
---|---|
TItem | An item. |
Release(TItem, TKey)
Returns a given item to the pool and registers it against a provided key.
Declaration
public void Release(TItem item, TKey key)
Parameters
Type | Name | Description |
---|---|---|
TItem | item | The item. |
TKey | key | The key to register the item against. |