Last change
on this file since 15771 was
15771,
checked in by bburlacu, 6 years ago
|
#2895: Add solution skeleton for PushGP with genealogy analysis.
|
File size:
622 bytes
|
Line | |
---|
1 | namespace HeuristicLab.Problems.ProgramSynthesis { |
---|
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 | resetor(item);
|
---|
19 | pool.Free(this);
|
---|
20 | }
|
---|
21 |
|
---|
22 | public void Reset() {
|
---|
23 | resetor(item);
|
---|
24 | }
|
---|
25 | }
|
---|
26 | }
|
---|
Note: See
TracBrowser
for help on using the repository browser.