Changeset 11900 for branches/ProgrammableProblem/HeuristicLab.Problems.Programmable/3.3/New/Scripts/ProblemDefinitionScript.cs
- Timestamp:
- 02/05/15 10:19:37 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/ProgrammableProblem/HeuristicLab.Problems.Programmable/3.3/New/Scripts/ProblemDefinitionScript.cs
r11885 r11900 55 55 } 56 56 57 private readonly object locker= new object();57 private readonly object compileLock = new object(); 58 58 private volatile IProblemDefinition compiledProblemDefinition; 59 59 protected IProblemDefinition CompiledProblemDefinition { 60 60 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 } 62 69 return compiledProblemDefinition; 63 }64 private set {65 compiledProblemDefinition = value;66 OnProblemDefinitionChanged();67 70 } 68 71 } 69 72 70 public override Assembly Compile() { 73 public sealed override Assembly Compile() { 74 return Compile(true); 75 } 76 77 protected virtual Assembly Compile(bool fireChanged) { 71 78 var assembly = base.Compile(); 72 79 var types = assembly.GetTypes(); … … 93 100 94 101 try { 95 CompiledProblemDefinition = inst; 102 compiledProblemDefinition = inst; 103 if (fireChanged) OnProblemDefinitionChanged(); 96 104 } catch (Exception e) { 97 105 compiledProblemDefinition = null;
Note: See TracChangeset
for help on using the changeset viewer.