Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
08/21/17 11:33:53 (7 years ago)
Author:
pkimmesw
Message:

#2665 Testet Problems, Testet error functions, Small fixes, Created HL files

Location:
branches/PushGP/HeuristicLab.PushGP
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • branches/PushGP/HeuristicLab.PushGP

    • Property svn:ignore
      •  

        old new  
        11*.user
         2packages
         3TestResults
  • branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis/Push/Data/Pool/IPooledObject.cs

    r15189 r15334  
    11namespace HeuristicLab.Problems.ProgramSynthesis.Push.Data.Pool {
    22  public interface IPooledObject {
    3     void Init();
    43    void Reset();
    54  }
  • branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis/Push/Data/Pool/ManagedPoolProvider.cs

    r15189 r15334  
    77  using System.Reflection;
    88  using System.Runtime.Serialization.Formatters.Binary;
     9
     10  using Microsoft.IO;
    911
    1012  public interface IManagedPool<T> : IDisposable where T : class, IPooledObject {
     
    1719    private readonly ObjectPool<IManagedPool<T>> managedPools;
    1820    private readonly BinaryFormatter binaryFormatter = new BinaryFormatter();
     21    private readonly RecyclableMemoryStreamManager recyclableMemoryStreamManager = new RecyclableMemoryStreamManager();
    1922    private byte[] dummyPartition;
    20     private static volatile object dummyCreationLockObject = new object();
     23    private volatile object dummyCreationLockObject = new object();
    2124
    2225    private static readonly FieldInfo InternalListArrayProperty = typeof(List<T[]>).GetField(
     
    5659
    5760    private T[] CloneDummyPartition() {
     61      // init dummy partition
    5862      if (dummyPartition == null) {
    5963        lock (dummyCreationLockObject) {
     
    6569            }
    6670
    67             using (var memoryStream = new MemoryStream()) {
    68               binaryFormatter.Serialize(memoryStream, temp);
    69               dummyPartition = memoryStream.ToArray();
     71            using (var ms = recyclableMemoryStreamManager.GetStream("dummyPartition")) {
     72              binaryFormatter.Serialize(ms, temp);
     73              dummyPartition = ms.ToArray();
    7074            }
    7175          }
     
    7377      }
    7478
    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);
    8382        return result;
    8483      }
  • branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis/Push/Data/Pool/PooledList.cs

    r15189 r15334  
    66  [Serializable]
    77  public class PooledList<T> : List<T>, IPooledObject {
    8     public Guid Id { get; private set; }
    9 
    10     void IPooledObject.Init() {
    11       Id = Guid.NewGuid();
    12     }
    138
    149    void IPooledObject.Reset() {
  • branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis/Push/Data/Pool/PooledObject.cs

    r15189 r15334  
    2020    }
    2121
    22     void IPooledObject.Init() { }
    23 
    2422    public void Reset() {
    2523      resetor(item);
Note: See TracChangeset for help on using the changeset viewer.