Free cookie consent management tool by TermsFeed Policy Generator

source: branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis/Push/Data/Pool/PooledObject.cs @ 14834

Last change on this file since 14834 was 14834, checked in by pkimmesw, 7 years ago

#2665 LexicaseSelector, Performance improvements, UI Fixes, Debugger only shows used stacks, fixed Debugger stepping, Added vector expressions, ERCOptions,

File size: 663 bytes
Line 
1namespace HeuristicLab.Problems.ProgramSynthesis.Push.Data.Pool {
2  using System;
3
4  public class PooledObject<T> : IDisposable, IPooledObject
5    where T : class {
6
7    private readonly ObjectPool<PooledObject<T>> pool;
8    private readonly T item;
9    private readonly Action<T> resetor;
10
11    public PooledObject(ObjectPool<PooledObject<T>> pool, T item, Action<T> resetor) {
12      this.pool = pool;
13      this.item = item;
14      this.resetor = resetor;
15    }
16
17    public virtual void Dispose() {
18      this.resetor(this.item);
19      this.pool.Free(this);
20    }
21
22    public void Reset() {
23      this.resetor(this.item);
24    }
25  }
26}
Note: See TracBrowser for help on using the repository browser.