Changeset 6356
- Timestamp:
- 06/04/11 17:16:37 (13 years ago)
- Location:
- trunk/sources/HeuristicLab.Persistence/3.3
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Persistence/3.3/Core/ConfigurationService.cs
r5445 r6356 42 42 43 43 private static ConfigurationService instance; 44 private static object locker = new object(); 44 45 private readonly Dictionary<IFormat, Configuration> customConfigurations; 45 46 … … 65 66 public static ConfigurationService Instance { 66 67 get { 67 if (instance == null) 68 instance = new ConfigurationService(); 69 return instance; 68 lock (locker) { 69 if (instance == null) 70 instance = new ConfigurationService(); 71 return instance; 72 } 70 73 } 71 74 } -
trunk/sources/HeuristicLab.Persistence/3.3/Default/CompositeSerializers/NumberEnumerable2StringSerializer.cs
r5445 r6356 46 46 47 47 private static readonly Dictionary<Type, Type> interfaceCache = new Dictionary<Type, Type>(); 48 private static readonly object locker = new object(); 48 49 49 50 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 } 58 61 } 62 interfaceCache.Add(type, null); 59 63 } 60 interfaceCache.Add(type, null);61 64 return null; 62 65 } -
trunk/sources/HeuristicLab.Persistence/3.3/Default/CompositeSerializers/Storable/StorableReflection.cs
r5445 r6356 124 124 /// <param name="storableMemberInfos"></param> 125 125 /// <returns></returns> 126 private static IEnumerable<StorableMemberInfo> DisentangleNameMapping( 127 IEnumerable<StorableMemberInfo> storableMemberInfos) { 126 private static IEnumerable<StorableMemberInfo> DisentangleNameMapping(IEnumerable<StorableMemberInfo> storableMemberInfos) { 128 127 var nameGrouping = new Dictionary<string, List<StorableMemberInfo>>(); 129 128 foreach (StorableMemberInfo storable in storableMemberInfos) { -
trunk/sources/HeuristicLab.Persistence/3.3/Tests/HeuristicLab.Persistence-3.3.Tests.csproj
r4065 r6356 107 107 </ItemGroup> 108 108 <ItemGroup> 109 <ProjectReference Include="..\..\..\HeuristicLab.Algorithms.GeneticAlgorithm\3.3\HeuristicLab.Algorithms.GeneticAlgorithm-3.3.csproj"> 110 <Project>{A51DA44F-CB35-4F6F-99F5-2A2E904AB93B}</Project> 111 <Name>HeuristicLab.Algorithms.GeneticAlgorithm-3.3</Name> 112 </ProjectReference> 109 113 <ProjectReference Include="..\HeuristicLab.Persistence-3.3.csproj"> 110 114 <Project>{102BC7D3-0EF9-439C-8F6D-96FF0FDB8E1B}</Project> -
trunk/sources/HeuristicLab.Persistence/3.3/Tests/UseCases.cs
r6342 r6356 39 39 using HeuristicLab.Persistence.Interfaces; 40 40 using Microsoft.VisualStudio.TestTools.UnitTesting; 41 using System.Threading.Tasks; 42 using HeuristicLab.Algorithms.GeneticAlgorithm; 41 43 42 44 namespace HeuristicLab.Persistence_33.Tests { … … 1271 1273 } 1272 1274 1273 1275 [TestMethod] 1276 public void ConcurrencyTest() { 1277 int n = 20; 1278 Task[] tasks = new Task[n]; 1279 for (int i = 0; i < n; i++) { 1280 tasks[i] = Task.Factory.StartNew((idx) => { 1281 byte[] data; 1282 using(var stream = new MemoryStream()) { 1283 XmlGenerator.Serialize(new GeneticAlgorithm(), stream); 1284 data = stream.ToArray(); 1285 } 1286 }, i); 1287 } 1288 Task.WaitAll(tasks); 1289 } 1274 1290 1275 1291 [ClassInitialize]
Note: See TracChangeset
for help on using the changeset viewer.