namespace HeuristicLab.Problems.ProgramSynthesis.Push.Data.Pool { using System; public class PooledObject : IDisposable, IPooledObject where T : class { private readonly ObjectPool> pool; private readonly T item; private readonly Action resetor; public PooledObject(ObjectPool> pool, T item, Action resetor) { this.pool = pool; this.item = item; this.resetor = resetor; } public virtual void Dispose() { resetor(item); pool.Free(this); } public void Reset() { resetor(item); } } }