Class ObjectPool<T>

Describes a simple object pool.

Inheritance
System.Object
Disposable
ObjectPool<T>
Implements
IDisposableEx
System.IDisposable
System.IAsyncDisposable
System.Collections.Generic.IReadOnlyCollection<T>
System.Collections.Generic.IEnumerable<T>
System.Collections.IEnumerable
Inherited Members
Disposable.AsyncDispose()
Disposable.CheckNotDisposed()
Disposable.Dispose()
Disposable.DisposeAsync()
Disposable.Disposed
Disposable.Disposing
Namespace: Solti.Utils.Primitives.Threading
Assembly: Solti.Utils.Primitives.dll
Syntax
public class ObjectPool<T> : Disposable, IDisposableEx where T : class
Type Parameters
Name Description
T

Constructors

ObjectPool(ILifetimeManager<T>, PoolConfig)

Creates a new ObjectPool<T> object.

Declaration
public ObjectPool(ILifetimeManager<T> lifetimeManager, PoolConfig config = null)
Parameters
Type Name Description
ILifetimeManager<T> lifetimeManager
PoolConfig config

ObjectPool(Func<T>, PoolConfig)

Creates a new ObjectPool<T> object.

Declaration
public ObjectPool(Func<T> factory, PoolConfig config = null)
Parameters
Type Name Description
System.Func<T> factory
PoolConfig config

Properties

Config

The pool configuration.

Declaration
public PoolConfig Config { get; }
Property Value
Type Description
PoolConfig

Count

The count of created objects.

Declaration
public int Count { get; }
Property Value
Type Description
System.Int32

LifetimeManager

The ILifetimeManager<T> of the items exposed by this pool.

Declaration
public ILifetimeManager<T> LifetimeManager { get; }
Property Value
Type Description
ILifetimeManager<T>

Methods

Dispose(Boolean)

Method to be overridden to implement custom disposal logic.

Declaration
protected override void Dispose(bool disposeManaged)
Parameters
Type Name Description
System.Boolean disposeManaged

It is set to true on System.IDisposable.Dispose call.

Overrides
Disposable.Dispose(Boolean)

Get(CancellationToken)

Gets a value from the pool.

Declaration
public IPoolItem<T> Get(CancellationToken cancellation = null)
Parameters
Type Name Description
System.Threading.CancellationToken cancellation
Returns
Type Description
IPoolItem<T>

GetEnumerator()

Enumerates the already produced items.

Declaration
public IEnumerator<T> GetEnumerator()
Returns
Type Description
System.Collections.Generic.IEnumerator<T>

Implements

IDisposableEx
System.IDisposable
System.IAsyncDisposable
System.Collections.Generic.IReadOnlyCollection<>
System.Collections.Generic.IEnumerable<>
System.Collections.IEnumerable
In This Article
Back to top Generated by DocFX