Show / Hide Table of Contents

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
IObjectPool<T>
System.Collections.Generic.IEnumerable<T>
System.Collections.IEnumerable
Namespace: Eco.Shared.Pools
Assembly: Eco.Shared.dll
Syntax
public class ThreadUnsafeFixedSizePool<T> : Object, IObjectPool<T>, IEnumerable<T>, IEnumerable where T : class
Type Parameters
Name Description
T

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
public void Clear()

Get()

Declaration
public T Get()
Returns
Type Description
T

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

IObjectPool<T>
System.Collections.Generic.IEnumerable<>
System.Collections.IEnumerable

Extension Methods

CommandLine.FeedFromCommandLine(Object)
CommandLine.ToCommandLineArgs(Object, Func<Object, Boolean>)
ListUtil.DepthFirstTraversal<T>(T, Func<T, IEnumerable<T>>)
EnumerableExtensions.SingleItemAsEnumerable<T>(T)
EventUtils.RaiseEvent<TEventArgs>(Object, String, TEventArgs)
PredicateUtils.MatchesAll<TEnumerable, T>(T, TEnumerable)
PredicateUtils.MatchesAll<T>(T, Func<T, Boolean>[])
PredicateUtils.MatchesAny<TEnumerable, T>(T, TEnumerable)
ReflectionUtils.PropertyValue<T>(Object, PropertyInfo)
ReflectionUtils.TryGetPropertyValueByName<T>(Object, String, out T)
ReflectionUtils.GetPropertyValueByName<T>(Object, String)
ReflectionUtils.SetPropertyByName(Object, String, Object)
ReflectionUtils.GetStructPropertyByName<T>(Object, String)
ReflectionUtils.GetStringPropertyByName(Object, String)
ReflectionUtils.ZipByProperty<T>(Object, Object, Object, Func<T, T, T>)
☀
☾
In This Article
Back to top
Copyright (c) Strange Loop Games 2021
☀
☾