Changeset 15334 for branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis/Push/Data
- Timestamp:
- 08/21/17 11:33:53 (7 years ago)
- Location:
- branches/PushGP/HeuristicLab.PushGP
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/PushGP/HeuristicLab.PushGP
- Property svn:ignore
-
old new 1 1 *.user 2 packages 3 TestResults
-
- Property svn:ignore
-
branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis/Push/Data/Pool/IPooledObject.cs
r15189 r15334 1 1 namespace HeuristicLab.Problems.ProgramSynthesis.Push.Data.Pool { 2 2 public interface IPooledObject { 3 void Init();4 3 void Reset(); 5 4 } -
branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis/Push/Data/Pool/ManagedPoolProvider.cs
r15189 r15334 7 7 using System.Reflection; 8 8 using System.Runtime.Serialization.Formatters.Binary; 9 10 using Microsoft.IO; 9 11 10 12 public interface IManagedPool<T> : IDisposable where T : class, IPooledObject { … … 17 19 private readonly ObjectPool<IManagedPool<T>> managedPools; 18 20 private readonly BinaryFormatter binaryFormatter = new BinaryFormatter(); 21 private readonly RecyclableMemoryStreamManager recyclableMemoryStreamManager = new RecyclableMemoryStreamManager(); 19 22 private byte[] dummyPartition; 20 private staticvolatile object dummyCreationLockObject = new object();23 private volatile object dummyCreationLockObject = new object(); 21 24 22 25 private static readonly FieldInfo InternalListArrayProperty = typeof(List<T[]>).GetField( … … 56 59 57 60 private T[] CloneDummyPartition() { 61 // init dummy partition 58 62 if (dummyPartition == null) { 59 63 lock (dummyCreationLockObject) { … … 65 69 } 66 70 67 using (var m emoryStream = new MemoryStream()) {68 binaryFormatter.Serialize(m emoryStream, temp);69 dummyPartition = m emoryStream.ToArray();71 using (var ms = recyclableMemoryStreamManager.GetStream("dummyPartition")) { 72 binaryFormatter.Serialize(ms, temp); 73 dummyPartition = ms.ToArray(); 70 74 } 71 75 } … … 73 77 } 74 78 75 using (var memoryStream = new MemoryStream(dummyPartition)) { 76 memoryStream.Seek(0, SeekOrigin.Begin); 77 78 var result = (T[])binaryFormatter.Deserialize(memoryStream); 79 80 for (var i = 0; i < result.Length; i++) 81 result[i].Init(); 82 79 using (var ms = recyclableMemoryStreamManager.GetStream("dummyPartition", dummyPartition, 0, dummyPartition.Length)) { 80 ms.Seek(0, SeekOrigin.Begin); 81 var result = (T[])binaryFormatter.Deserialize(ms); 83 82 return result; 84 83 } -
branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis/Push/Data/Pool/PooledList.cs
r15189 r15334 6 6 [Serializable] 7 7 public class PooledList<T> : List<T>, IPooledObject { 8 public Guid Id { get; private set; }9 10 void IPooledObject.Init() {11 Id = Guid.NewGuid();12 }13 8 14 9 void IPooledObject.Reset() { -
branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis/Push/Data/Pool/PooledObject.cs
r15189 r15334 20 20 } 21 21 22 void IPooledObject.Init() { }23 24 22 public void Reset() { 25 23 resetor(item);
Note: See TracChangeset
for help on using the changeset viewer.