Class ThreadUnsafeFixedSizePool<T>
Thread-unsafe lock free System.Collections.Generic.Stack<> based pool implementation. It implements IObjectPool<T> interface and has fixed pool size.
You should prefer it to use over thread-safe pool implementations where you're sure it won't be used from multiple threads (in example in Unity components).
Inheritance
System.Object
ThreadUnsafeFixedSizePool<T>
Implements
System.Collections.Generic.IEnumerable<T>
System.Collections.IEnumerable
Assembly: Eco.Shared.dll
Syntax
public class ThreadUnsafeFixedSizePool<T> : Object, IObjectPool<T>, IEnumerable<T>, IEnumerable where T : class
Type Parameters
Constructors
ThreadUnsafeFixedSizePool(Int32)
Declaration
public ThreadUnsafeFixedSizePool(int maxSize)
Parameters
Type |
Name |
Description |
System.Int32 |
maxSize |
|
Properties
Count
Declaration
public int Count { get; }
Property Value
Type |
Description |
System.Int32 |
|
MaxSize
Max number of elements in pool.
It actually may be less than actual number of elements if MaxSize was reduced when Count > MaxSize.
In this case it will not add objects with TryAdd(T) until Count go below MaxSize.
Declaration
public int MaxSize { get; set; }
Property Value
Type |
Description |
System.Int32 |
|
Methods
CheckIsDuplicated(T)
Declaration
public void CheckIsDuplicated(T obj)
Parameters
Type |
Name |
Description |
T |
obj |
|
Clear()
Declaration
Get()
Declaration
Returns
GetEnumerator()
Declaration
public Stack<T>.Enumerator GetEnumerator()
Returns
Type |
Description |
System.Collections.Generic.Stack.Enumerator<> |
|
TryAdd(T)
Declaration
public bool TryAdd(T obj)
Parameters
Type |
Name |
Description |
T |
obj |
|
Returns
Type |
Description |
System.Boolean |
|
Implements
System.Collections.Generic.IEnumerable<>
System.Collections.IEnumerable
Extension Methods