Class ObjectPoolExtensions
Inheritance
System.Object
ObjectPoolExtensions
Assembly: Eco.Shared.dll
Syntax
public static class ObjectPoolExtensions : Object
Methods
AsService<T>(IObjectPool<T>, Action<T>)
Wraps pool
with PoolService<T> with default constructor for new pool elements and optional onReturn
cleanup method.
With this factory method
new PoolService<MyClass>(new MyPool<MyClass>(), () => new MyClass(), onReturn)
can be rewritten as
new MyPool<MyClass>().AsService(onReturn)
.
Declaration
public static PoolService<T> AsService<T>(this IObjectPool<T> pool, Action<T> onReturn = null)
where T : class, new()
Parameters
Type |
Name |
Description |
IObjectPool<T> |
pool |
|
System.Action<T> |
onReturn |
|
Returns
Type Parameters
AsService<T>(IObjectPool<T>, Func<T>, Action<T>)
Wraps pool
with PoolService<T> with factory
for new pool elements and optional onReturn
cleanup method.
With this factory method
new PoolService<MyClass>(new MyPool<MyClass>(), () => new MyClass("abc"))
can be rewritten as
new MyPool<MyClass>().AsService(() => new MyClass("abc"))
.
Declaration
public static PoolService<T> AsService<T>(this IObjectPool<T> pool, Func<T> factory, Action<T> onReturn = null)
where T : class
Parameters
Type |
Name |
Description |
IObjectPool<T> |
pool |
|
System.Func<T> |
factory |
|
System.Action<T> |
onReturn |
|
Returns
Type Parameters