Changeset 14746 for branches/PushGP/HeuristicLab.PushGP/TestPooling/Pool
- Timestamp:
- 03/11/17 20:07:13 (8 years ago)
- Location:
- branches/PushGP/HeuristicLab.PushGP/TestPooling/Pool
- Files:
-
- 2 deleted
- 1 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) {
Note: See TracChangeset
for help on using the changeset viewer.