Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
02/05/15 10:19:37 (9 years ago)
Author:
abeham
Message:

#2174:

  • Removed compilation calls from the problem (AfterDeserialization and in cloning constructor) and instead compile instance lazily when accessed
  • Compile support code in ExternalEvaluationProblem lazy
  • Fixed encoding class names in template code files (forgot to add vector)
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/ProgrammableProblem/HeuristicLab.Problems.Programmable/3.3/New/Scripts/ProblemDefinitionScript.cs

    r11885 r11900  
    5555    }
    5656
    57     private readonly object locker = new object();
     57    private readonly object compileLock = new object();
    5858    private volatile IProblemDefinition compiledProblemDefinition;
    5959    protected IProblemDefinition CompiledProblemDefinition {
    6060      get {
    61         if (compiledProblemDefinition == null) throw new InvalidOperationException("The problem definition script is not compiled and cannot be used.");
     61        // double checked locking pattern
     62        if (compiledProblemDefinition == null) {
     63          lock (compileLock) {
     64            if (compiledProblemDefinition == null) {
     65              Compile(false);
     66            }
     67          }
     68        }
    6269        return compiledProblemDefinition;
    63       }
    64       private set {
    65         compiledProblemDefinition = value;
    66         OnProblemDefinitionChanged();
    6770      }
    6871    }
    6972
    70     public override Assembly Compile() {
     73    public sealed override Assembly Compile() {
     74      return Compile(true);
     75    }
     76
     77    protected virtual Assembly Compile(bool fireChanged) {
    7178      var assembly = base.Compile();
    7279      var types = assembly.GetTypes();
     
    93100
    94101      try {
    95         CompiledProblemDefinition = inst;
     102        compiledProblemDefinition = inst;
     103        if (fireChanged) OnProblemDefinitionChanged();
    96104      } catch (Exception e) {
    97105        compiledProblemDefinition = null;
Note: See TracChangeset for help on using the changeset viewer.