# Class Pool
Namespace: [CapyKit](CapyKit.md)
Assembly: CapyKit.dll
A managed pool of resources. This class provides a thread-safe way to manage a collection of
objects of type T.
```csharp
public class Pool
```
#### Type Parameters
`T`
The type of objects to be managed by the pool.
#### Inheritance
[object](https://learn.microsoft.com/dotnet/api/system.object) ←
[Pool](CapyKit.Pool\-1.md)
#### Inherited Members
[object.Equals\(object?\)](https://learn.microsoft.com/dotnet/api/system.object.equals\#system\-object\-equals\(system\-object\)),
[object.Equals\(object?, object?\)](https://learn.microsoft.com/dotnet/api/system.object.equals\#system\-object\-equals\(system\-object\-system\-object\)),
[object.GetHashCode\(\)](https://learn.microsoft.com/dotnet/api/system.object.gethashcode),
[object.GetType\(\)](https://learn.microsoft.com/dotnet/api/system.object.gettype),
[object.MemberwiseClone\(\)](https://learn.microsoft.com/dotnet/api/system.object.memberwiseclone),
[object.ReferenceEquals\(object?, object?\)](https://learn.microsoft.com/dotnet/api/system.object.referenceequals),
[object.ToString\(\)](https://learn.microsoft.com/dotnet/api/system.object.tostring)
#### Extension Methods
[ObjectExtensions.UpdateProperties\>\(Pool, Pool\)](CapyKit.Extensions.ObjectExtensions.md\#CapyKit\_Extensions\_ObjectExtensions\_UpdateProperties\_\_1\_\_\_0\_\_\_0\_),
[ObjectExtensions.UpdateProperties\(object, object\)](CapyKit.Extensions.ObjectExtensions.md\#CapyKit\_Extensions\_ObjectExtensions\_UpdateProperties\_System\_Object\_System\_Object\_)
## Constructors
### Pool\(int\)
Initializes a new instance of the class with the specified pool size.
```csharp
public Pool(int poolSize)
```
#### Parameters
`poolSize` [int](https://learn.microsoft.com/dotnet/api/system.int32)
The size of the pool.
### Pool\(int, Func\)
Initializes a new instance of the class with the specified pool size
and constructor selector.
```csharp
public Pool(int poolSize, Func constructorSelector)
```
#### Parameters
`poolSize` [int](https://learn.microsoft.com/dotnet/api/system.int32)
The size of the pool.
`constructorSelector` [Func](https://learn.microsoft.com/dotnet/api/system.func\-1)
The constructor selector used to create new instances of T.
### Pool\(IEnumerable\)
Initializes a new instance of the class with the specified collection
of items.
```csharp
public Pool(IEnumerable collection)
```
#### Parameters
`collection` [IEnumerable](https://learn.microsoft.com/dotnet/api/system.collections.generic.ienumerable\-1)
The collection of T items with which to seed the pool.
## Methods
### GetAvailableItem\(\)
Gets the first available item from the pool and sets its lock.
```csharp
public PoolItem GetAvailableItem()
```
#### Returns
[PoolItem](CapyKit.PoolItem\-1.md)
The first available item from the pool.
### ReleaseItem\(PoolItem\)
Releases the lock on the specified item and returns it to the pool.
```csharp
public void ReleaseItem(PoolItem item)
```
#### Parameters
`item` [PoolItem](CapyKit.PoolItem\-1.md)
The item to release.
#### Remarks
This method sets the flag to false so that
it can be retrieved by .