Changeset 14746 for branches/PushGP/HeuristicLab.PushGP/TestPooling
- Timestamp:
- 03/11/17 20:07:13 (7 years ago)
- Location:
- branches/PushGP/HeuristicLab.PushGP/TestPooling
- Files:
-
- 2 deleted
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/PushGP/HeuristicLab.PushGP/TestPooling/Pool/ManagedPoolProvider.cs
r14745 r14746 8 8 using System.Runtime.Serialization.Formatters.Binary; 9 9 10 public interface IManagedPool<T> : IDisposable where T : class { 11 T Get(); 12 } 13 10 14 public class ManagedPoolProvider<T> where T : class { 11 15 private readonly ConcurrentStack<T[]> partitions = new ConcurrentStack<T[]>(); 12 16 private readonly ObjectPool<IManagedPool<T>> managedPools; 13 17 private T[] DummyPartition; 18 14 19 public readonly int PartitionSize; 20 public readonly int MaxParitionCount; 21 public const int DefaultMaxInstanceCount = 16384; 15 22 16 public int InstanceCount { get { return partitions.Count * PartitionSize; } } 23 public ManagedPoolProvider(int partitionSize, int maxPartitionCount = -1) { 24 PartitionSize = partitionSize; 17 25 18 public ManagedPoolProvider(int partitionSize) { 19 PartitionSize = partitionSize; 26 if (maxPartitionCount <= 0) { 27 MaxParitionCount = DefaultMaxInstanceCount / PartitionSize; 28 } 29 20 30 managedPools = new ObjectPool<IManagedPool<T>>(() => new ManagedPool2<T>(this)); 21 31 } … … 27 37 } 28 38 } 39 40 public int InstanceCount { get { return partitions.Count * PartitionSize; } } 29 41 30 42 public void ReleasePartitions(params T[][] partition) { -
branches/PushGP/HeuristicLab.PushGP/TestPooling/Program.cs
r14745 r14746 15 15 16 16 private static int TotalInstanceCount => PopulationCount * InstanceCount * ExampleCount; 17 18 17 19 18 static void Main(string[] args) { -
branches/PushGP/HeuristicLab.PushGP/TestPooling/TestPooling.csproj
r14745 r14746 44 44 </ItemGroup> 45 45 <ItemGroup> 46 <Compile Include="Pool\IManagedPool.cs" />47 46 <Compile Include="Pool\ManagedPool.cs" /> 48 <Compile Include="Pool\ManagedPool2.cs" />49 47 <Compile Include="Pool\ManagedPoolProvider.cs" /> 50 48 <Compile Include="Pool\ObjectPool.cs" />
Note: See TracChangeset
for help on using the changeset viewer.