Class ObjectRecycler<T>
Represents a pool of recyclable objects exposed through ObjectRecyclerToken<T> instances.
public abstract class ObjectRecycler<T> : IDisposable where T : class
Type Parameters
T
Object type.
- Inheritance
-
ObjectRecycler<T>
- Implements
- Inherited Members
- Extension Methods
Constructors
ObjectRecycler(int)
Creates a new ObjectRecycler<T> instance.
protected ObjectRecycler(int minCapacity = 0)
Parameters
minCapacity
intMinimum initial capacity of the underlying object buffer. Equal to 0 by default.
Properties
ActiveObjectCount
Specifies the number of currently active objects.
public int ActiveObjectCount { get; }
Property Value
ObjectCount
Specifies the total number of currently cached objects.
public int ObjectCount { get; }
Property Value
Methods
Create()
Creates a new object instance.
[Pure]
protected abstract T Create()
Returns
- T
New object instance.
Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
public void Dispose()
Exceptions
- AggregateException
When at least one stored object throws an exception during a call to its Dispose() method.
Free(T)
Performs additional obj
clean up during its move to the free object stack.
protected virtual void Free(T obj)
Parameters
obj
TObject to free.
Rent()
Creates a new ObjectRecyclerToken<T> instance from this recycler.
public ObjectRecyclerToken<T> Rent()
Returns
- ObjectRecyclerToken<T>
New ObjectRecyclerToken<T> instance.
Exceptions
- ObjectDisposedException
When this recycler has been disposed.
TrimExcess()
Attempts to dispose cached objects without modifying internal state.
public void TrimExcess()
Exceptions
- AggregateException
When at least one stored object throws an exception during a call to its Dispose() method.