Changeset 5193 for trunk/sources/HeuristicLab.Parameters
- Timestamp:
- 01/03/11 00:46:55 (14 years ago)
- Location:
- trunk/sources
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources
- Property svn:mergeinfo changed
/branches/ParallelEngine (added) merged: 5175-5178,5183,5185,5187-5188
- Property svn:mergeinfo changed
-
trunk/sources/HeuristicLab.Parameters/3.3/LookupParameter.cs
r4722 r5193 52 52 } 53 53 public new T ActualValue { 54 get { 55 if (cachedActualValue == null) cachedActualValue = GetActualValue(); 56 return (T)cachedActualValue; 57 } 58 set { 59 cachedActualValue = value; 60 SetActualValue(value); 61 } 54 get { return (T)base.ActualValue; } 55 set { base.ActualValue = value; } 62 56 } 63 57 -
trunk/sources/HeuristicLab.Parameters/3.3/Parameter.cs
r4722 r5193 22 22 using System; 23 23 using System.Drawing; 24 using System.Threading; 24 25 using HeuristicLab.Common; 25 26 using HeuristicLab.Core; … … 53 54 get { return dataType; } 54 55 } 55 protected IItem cachedActualValue; 56 57 private Lazy<ThreadLocal<IItem>> cachedActualValues; 56 58 public IItem ActualValue { 57 59 get { 58 if (cachedActualValue == null) cachedActualValue = GetActualValue();59 return cachedActualValue ;60 if (cachedActualValues.Value.Value == null) cachedActualValues.Value.Value = GetActualValue(); 61 return cachedActualValues.Value.Value; 60 62 } 61 63 set { 62 cachedActualValue = value;64 cachedActualValues.Value.Value = value; 63 65 SetActualValue(value); 64 66 } 65 67 } 66 [Storable] 67 private IExecutionContext executionContext; 68 private Lazy<ThreadLocal<IExecutionContext>> executionContexts; 68 69 public IExecutionContext ExecutionContext { 69 get { return executionContext ; }70 get { return executionContexts.Value.Value; } 70 71 set { 71 if (value != executionContext) { 72 executionContext = value; 73 cachedActualValue = null; 74 OnExecutionContextChanged(); 72 if (value != executionContexts.Value.Value) { 73 executionContexts.Value.Value = value; 74 cachedActualValues.Value.Value = null; 75 75 } 76 76 } … … 78 78 79 79 [StorableConstructor] 80 protected Parameter(bool deserializing) : base(deserializing) { } 80 protected Parameter(bool deserializing) 81 : base(deserializing) { 82 cachedActualValues = new Lazy<ThreadLocal<IItem>>(() => { return new ThreadLocal<IItem>(); }, LazyThreadSafetyMode.ExecutionAndPublication); 83 executionContexts = new Lazy<ThreadLocal<IExecutionContext>>(() => { return new ThreadLocal<IExecutionContext>(); }, LazyThreadSafetyMode.ExecutionAndPublication); 84 } 81 85 protected Parameter(Parameter original, Cloner cloner) 82 86 : base(original, cloner) { 83 87 dataType = original.dataType; 84 executionContext = cloner.Clone(original.executionContext); 88 cachedActualValues = new Lazy<ThreadLocal<IItem>>(() => { return new ThreadLocal<IItem>(); }, LazyThreadSafetyMode.ExecutionAndPublication); 89 executionContexts = new Lazy<ThreadLocal<IExecutionContext>>(() => { return new ThreadLocal<IExecutionContext>(); }, LazyThreadSafetyMode.ExecutionAndPublication); 85 90 } 86 91 protected Parameter() 87 92 : base("Anonymous") { 88 93 dataType = typeof(IItem); 94 cachedActualValues = new Lazy<ThreadLocal<IItem>>(() => { return new ThreadLocal<IItem>(); }, LazyThreadSafetyMode.ExecutionAndPublication); 95 executionContexts = new Lazy<ThreadLocal<IExecutionContext>>(() => { return new ThreadLocal<IExecutionContext>(); }, LazyThreadSafetyMode.ExecutionAndPublication); 89 96 } 90 97 protected Parameter(string name, Type dataType) … … 92 99 if (dataType == null) throw new ArgumentNullException(); 93 100 this.dataType = dataType; 101 cachedActualValues = new Lazy<ThreadLocal<IItem>>(() => { return new ThreadLocal<IItem>(); }, LazyThreadSafetyMode.ExecutionAndPublication); 102 executionContexts = new Lazy<ThreadLocal<IExecutionContext>>(() => { return new ThreadLocal<IExecutionContext>(); }, LazyThreadSafetyMode.ExecutionAndPublication); 94 103 } 95 104 protected Parameter(string name, string description, Type dataType) … … 97 106 if (dataType == null) throw new ArgumentNullException(); 98 107 this.dataType = dataType; 108 cachedActualValues = new Lazy<ThreadLocal<IItem>>(() => { return new ThreadLocal<IItem>(); }, LazyThreadSafetyMode.ExecutionAndPublication); 109 executionContexts = new Lazy<ThreadLocal<IExecutionContext>>(() => { return new ThreadLocal<IExecutionContext>(); }, LazyThreadSafetyMode.ExecutionAndPublication); 99 110 } 100 111 … … 105 116 protected abstract IItem GetActualValue(); 106 117 protected abstract void SetActualValue(IItem value); 107 108 protected virtual void OnExecutionContextChanged() { }109 118 } 110 119 }
Note: See TracChangeset
for help on using the changeset viewer.