Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
06/04/11 17:16:37 (14 years ago)
Author:
epitzer
Message:

Added additional locks to improve concurrent persistence (#1544)

Location:
trunk/sources/HeuristicLab.Persistence/3.3/Default/CompositeSerializers
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Persistence/3.3/Default/CompositeSerializers/NumberEnumerable2StringSerializer.cs

    r5445 r6356  
    4646
    4747    private static readonly Dictionary<Type, Type> interfaceCache = new Dictionary<Type, Type>();
     48    private static readonly object locker = new object();
    4849
    4950    public Type GetGenericEnumerableInterface(Type type) {
    50       if (interfaceCache.ContainsKey(type))
    51         return interfaceCache[type];
    52       foreach (Type iface in type.GetInterfaces()) {
    53         if (iface.IsGenericType &&
    54           iface.GetGenericTypeDefinition() == typeof(IEnumerable<>) &&
    55           numberConverter.CanSerialize(iface.GetGenericArguments()[0])) {
    56           interfaceCache.Add(type, iface);
    57           return iface;
     51      lock (locker) {
     52        if (interfaceCache.ContainsKey(type))
     53          return interfaceCache[type];
     54        foreach (Type iface in type.GetInterfaces()) {
     55          if (iface.IsGenericType &&
     56            iface.GetGenericTypeDefinition() == typeof(IEnumerable<>) &&
     57            numberConverter.CanSerialize(iface.GetGenericArguments()[0])) {
     58            interfaceCache.Add(type, iface);
     59            return iface;
     60          }
    5861        }
     62        interfaceCache.Add(type, null);
    5963      }
    60       interfaceCache.Add(type, null);
    6164      return null;
    6265    }
  • trunk/sources/HeuristicLab.Persistence/3.3/Default/CompositeSerializers/Storable/StorableReflection.cs

    r5445 r6356  
    124124    /// <param name="storableMemberInfos"></param>
    125125    /// <returns></returns>
    126     private static IEnumerable<StorableMemberInfo> DisentangleNameMapping(
    127         IEnumerable<StorableMemberInfo> storableMemberInfos) {
     126    private static IEnumerable<StorableMemberInfo> DisentangleNameMapping(IEnumerable<StorableMemberInfo> storableMemberInfos) {
    128127      var nameGrouping = new Dictionary<string, List<StorableMemberInfo>>();
    129128      foreach (StorableMemberInfo storable in storableMemberInfos) {
Note: See TracChangeset for help on using the changeset viewer.