Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
01/03/11 00:46:55 (13 years ago)
Author:
swagner
Message:

Merged ParallelEngine branch back into trunk (#1333)

Location:
trunk/sources
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources

  • trunk/sources/HeuristicLab.Parameters/3.3/LookupParameter.cs

    r4722 r5193  
    5252    }
    5353    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; }
    6256    }
    6357
  • trunk/sources/HeuristicLab.Parameters/3.3/Parameter.cs

    r4722 r5193  
    2222using System;
    2323using System.Drawing;
     24using System.Threading;
    2425using HeuristicLab.Common;
    2526using HeuristicLab.Core;
     
    5354      get { return dataType; }
    5455    }
    55     protected IItem cachedActualValue;
     56
     57    private Lazy<ThreadLocal<IItem>> cachedActualValues;
    5658    public IItem ActualValue {
    5759      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;
    6062      }
    6163      set {
    62         cachedActualValue = value;
     64        cachedActualValues.Value.Value = value;
    6365        SetActualValue(value);
    6466      }
    6567    }
    66     [Storable]
    67     private IExecutionContext executionContext;
     68    private Lazy<ThreadLocal<IExecutionContext>> executionContexts;
    6869    public IExecutionContext ExecutionContext {
    69       get { return executionContext; }
     70      get { return executionContexts.Value.Value; }
    7071      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;
    7575        }
    7676      }
     
    7878
    7979    [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    }
    8185    protected Parameter(Parameter original, Cloner cloner)
    8286      : base(original, cloner) {
    8387      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);
    8590    }
    8691    protected Parameter()
    8792      : base("Anonymous") {
    8893      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);
    8996    }
    9097    protected Parameter(string name, Type dataType)
     
    9299      if (dataType == null) throw new ArgumentNullException();
    93100      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);
    94103    }
    95104    protected Parameter(string name, string description, Type dataType)
     
    97106      if (dataType == null) throw new ArgumentNullException();
    98107      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);
    99110    }
    100111
     
    105116    protected abstract IItem GetActualValue();
    106117    protected abstract void SetActualValue(IItem value);
    107 
    108     protected virtual void OnExecutionContextChanged() { }
    109118  }
    110119}
Note: See TracChangeset for help on using the changeset viewer.