Free cookie consent management tool by TermsFeed Policy Generator

Changeset 13203 for trunk/sources


Ignore:
Timestamp:
11/17/15 09:58:35 (9 years ago)
Author:
pfleck
Message:

#1674 Made CacheEntry thread-safe. Renamed the persistence properties for more clarity.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Problems.ExternalEvaluation/3.4/EvaluationCache.cs

    r13180 r13203  
    5252      private byte[] rawMessage;
    5353
     54      private object lockObject = new object();
     55
    5456      public byte[] RawMessage {
    5557        get { return rawMessage; }
    5658        set {
    57           rawMessage = value;
    58           message = null;
     59          lock (lockObject) {
     60            rawMessage = value;
     61            message = null;
     62          }
    5963        }
    6064      }
     
    6569
    6670      public QualityMessage GetMessage(ExtensionRegistry extensions) {
    67         if (message == null && rawMessage != null)
    68           message = QualityMessage.ParseFrom(ByteString.CopyFrom(rawMessage), extensions);
     71        lock (lockObject) {
     72          if (message == null && rawMessage != null)
     73            message = QualityMessage.ParseFrom(ByteString.CopyFrom(rawMessage), extensions);
     74        }
    6975        return message;
    7076      }
    7177      public void SetMessage(QualityMessage value) {
    72         message = value;
    73         rawMessage = value.ToByteArray();
     78        lock (lockObject) {
     79          message = value;
     80          rawMessage = value.ToByteArray();
     81        }
    7482      }
    7583
     
    164172    #region BackwardsCompatibility3.4
    165173    [Storable(Name = "Cache")]
    166     private IEnumerable<KeyValuePair<string, double>> Cache_Persistence {
     174    private IEnumerable<KeyValuePair<string, double>> Cache_Persistence_backwardscompatability {
    167175      get { return Enumerable.Empty<KeyValuePair<string, double>>(); }
    168176      set {
     
    179187    #endregion
    180188    [Storable(Name = "CacheNew")]
    181     private IEnumerable<KeyValuePair<string, byte[]>> CacheNew_Persistence {
     189    private IEnumerable<KeyValuePair<string, byte[]>> Cache_Persistence {
    182190      get { return IsPersistent ? GetCacheValues() : Enumerable.Empty<KeyValuePair<string, byte[]>>(); }
    183191      set { SetCacheValues(value); }
Note: See TracChangeset for help on using the changeset viewer.