Changeset 15017 for branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis/Push/Interpreter/PushInterpreterPool.cs
- Timestamp:
- 06/01/17 09:28:34 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis/Push/Interpreter/PushInterpreterPool.cs
r14834 r15017 11 11 12 12 public readonly ManagedPoolProvider<PushProgram> PushProgramPoolProvider; 13 public readonly ManagedPoolProvider<LoopState> LoopStatePoolProvider;14 13 public readonly ManagedPoolProvider<PooledList<Expression>> ExpressionListPoolProvider; 15 14 … … 19 18 20 19 public PushInterpreterPool(int size, int poolPartitionSize, int? maxPartitionCount = null, IReadOnlyPushConfiguration config = null) { 21 Push GpConfiguration = config ?? new PushConfiguration();20 PushConfiguration = config ?? new PushConfiguration(); 22 21 23 22 PushProgramPoolProvider = new ManagedPoolProvider<PushProgram>(poolPartitionSize, () => new PushProgram(), maxPartitionCount); 24 LoopStatePoolProvider = new ManagedPoolProvider<LoopState>(poolPartitionSize, () => new LoopState(), maxPartitionCount); 25 ExpressionListPoolProvider = new ManagedPoolProvider<PooledList<Expression>>(poolPartitionSize * 2, () => new PooledList<Expression>(), maxPartitionCount); 23 ExpressionListPoolProvider = new ManagedPoolProvider<PooledList<Expression>>(poolPartitionSize, () => new PooledList<Expression>(), maxPartitionCount); 26 24 27 25 pool = new ObjectPool<PooledPushInterpreter>(() => { 28 var poolContainer = new InterpreterPoolContainer(PushProgramPoolProvider, LoopStatePoolProvider,ExpressionListPoolProvider);29 return new PooledPushInterpreter(this, Push GpConfiguration, poolContainer);26 var poolContainer = new InterpreterPoolContainer(PushProgramPoolProvider, ExpressionListPoolProvider); 27 return new PooledPushInterpreter(this, PushConfiguration, poolContainer); 30 28 }, size); 31 29 } 32 30 33 public IReadOnlyPushConfiguration Push GpConfiguration { get; private set; }31 public IReadOnlyPushConfiguration PushConfiguration { get; private set; } 34 32 35 33 public PooledPushInterpreter Create(IRandom random = null) { … … 41 39 42 40 public void Free(PooledPushInterpreter interpreter) { 41 interpreter.Random = null; 43 42 pool.Free(interpreter); 43 } 44 45 public void Clear() { 46 PushProgramPoolProvider.Clear(); 47 ExpressionListPoolProvider.Clear(); 44 48 } 45 49 }
Note: See TracChangeset
for help on using the changeset viewer.