ObjectPool<T> class
A simple object pool to reduce memory allocations and garbage collection pressure.
Constructors
- ObjectPool({required T factory(), void reset(T)?, int maxSize = 50})
-
Creates a new
ObjectPool.
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
acquire(
) → T - Acquires an object from the pool. If the pool is empty, a new object is created using the factory.
-
clear(
) → void - Clears all objects from the pool.
-
getStats(
) → Map< String, int> - Returns a map with statistics about the pool.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
release(
T object) → void - Releases an object back to the pool.
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited