Changeset 7215 for branches/HeuristicLab.Hive.Azure/HeuristicLab.Core/3.3
- Timestamp:
- 12/20/11 13:54:57 (13 years ago)
- Location:
- branches/HeuristicLab.Hive.Azure
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.Hive.Azure
- Property svn:ignore
-
old new 4 4 *.suo 5 5 *.vsp 6 Doxygen 6 7 Google.ProtocolBuffers-0.9.1.dll 7 8 HeuristicLab 3.3.5.1.ReSharper.user 8 9 HeuristicLab 3.3.6.0.ReSharper.user 9 10 HeuristicLab.4.5.resharper.user 11 HeuristicLab.ExtLibs.6.0.ReSharper.user 10 12 HeuristicLab.resharper.user 11 13 ProtoGen.exe … … 16 18 bin 17 19 protoc.exe 18 HeuristicLab.ExtLibs.6.0.ReSharper.user19 Doxygen
-
- Property svn:mergeinfo changed
- Property svn:ignore
-
branches/HeuristicLab.Hive.Azure/HeuristicLab.Core/3.3/ThreadSafeLog.cs
r6862 r7215 30 30 [Item("ThreadSafeLog", "A thread-safe log for logging string messages.")] 31 31 [StorableClass] 32 public class ThreadSafeLog : Log, IDeepCloneable{33 pr otectedReaderWriterLockSlim locker = new ReaderWriterLockSlim();32 public sealed class ThreadSafeLog : Log { 33 private ReaderWriterLockSlim locker = new ReaderWriterLockSlim(); 34 34 35 35 public override IEnumerable<string> Messages { … … 38 38 try { 39 39 return messages.ToArray(); // return copy of messages 40 } 41 finally { locker.ExitReadLock(); } 40 } finally { locker.ExitReadLock(); } 42 41 } 43 42 } 44 43 45 44 [StorableConstructor] 46 pr otectedThreadSafeLog(bool deserializing) : base(deserializing) { }45 private ThreadSafeLog(bool deserializing) : base(deserializing) { } 47 46 public ThreadSafeLog(long maxMessageCount = -1) 48 47 : base(maxMessageCount) { 49 48 } 50 49 51 protected ThreadSafeLog(ThreadSafeLog original, Cloner cloner) { 52 original.locker.EnterReadLock(); 53 try { 54 cloner.RegisterClonedObject(original, this); 55 this.messages = new List<string>(original.messages); 56 this.maxMessageCount = original.maxMessageCount; 57 } 58 finally { original.locker.ExitReadLock(); } 59 } 50 private ThreadSafeLog(ThreadSafeLog original, Cloner cloner) 51 : base(original, cloner) { } 60 52 61 53 public override IDeepCloneable Clone(Cloner cloner) { 62 return new ThreadSafeLog(this, cloner); 54 locker.EnterReadLock(); 55 try { 56 return new ThreadSafeLog(this, cloner); 57 } finally { locker.ExitReadLock(); } 63 58 } 64 59 … … 67 62 try { 68 63 messages.Clear(); 69 } 70 finally { locker.ExitWriteLock(); } 64 } finally { locker.ExitWriteLock(); } 71 65 OnCleared(); 72 66 } … … 78 72 messages.Add(s); 79 73 CapMessages(); 80 } 81 finally { locker.ExitWriteLock(); } 74 } finally { locker.ExitWriteLock(); } 82 75 OnMessageAdded(s); 83 76 } … … 89 82 messages.Add(s); 90 83 CapMessages(); 91 } 92 finally { locker.ExitWriteLock(); } 84 } finally { locker.ExitWriteLock(); } 93 85 OnMessageAdded(s); 94 86 }
Note: See TracChangeset
for help on using the changeset viewer.