aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework
diff options
context:
space:
mode:
authorJeff Ames2009-06-09 18:07:35 +0000
committerJeff Ames2009-06-09 18:07:35 +0000
commita7fcacf8f396acbca0b640a65acfbf5487d513e7 (patch)
tree5ba66f5c83eceeb81e24a0540ae4fac9847e0c78 /OpenSim/Framework
parentUpdate svn properties. (diff)
downloadopensim-SC-a7fcacf8f396acbca0b640a65acfbf5487d513e7.zip
opensim-SC-a7fcacf8f396acbca0b640a65acfbf5487d513e7.tar.gz
opensim-SC-a7fcacf8f396acbca0b640a65acfbf5487d513e7.tar.bz2
opensim-SC-a7fcacf8f396acbca0b640a65acfbf5487d513e7.tar.xz
Formatting cleanup. Ignore some generated files.
Diffstat (limited to '')
-rw-r--r--OpenSim/Framework/CnmMemoryCache.cs246
-rw-r--r--OpenSim/Framework/CnmSynchronizedCache.cs77
-rw-r--r--OpenSim/Framework/PrimeNumberHelper.cs26
3 files changed, 175 insertions, 174 deletions
diff --git a/OpenSim/Framework/CnmMemoryCache.cs b/OpenSim/Framework/CnmMemoryCache.cs
index 77ca10c..db91801 100644
--- a/OpenSim/Framework/CnmMemoryCache.cs
+++ b/OpenSim/Framework/CnmMemoryCache.cs
@@ -81,7 +81,7 @@ namespace OpenSim.Framework
81 /// 30 minutes. 81 /// 30 minutes.
82 /// </para> 82 /// </para>
83 /// </remarks> 83 /// </remarks>
84 public static readonly TimeSpan DefaultExpirationTime = TimeSpan.FromMinutes( 30.0 ); 84 public static readonly TimeSpan DefaultExpirationTime = TimeSpan.FromMinutes(30.0);
85 85
86 /// <summary> 86 /// <summary>
87 /// Minimal allowed expiration time. 87 /// Minimal allowed expiration time.
@@ -91,7 +91,7 @@ namespace OpenSim.Framework
91 /// 5 minutes. 91 /// 5 minutes.
92 /// </para> 92 /// </para>
93 /// </remarks> 93 /// </remarks>
94 public static readonly TimeSpan MinExpirationTime = TimeSpan.FromSeconds( 10.0 ); 94 public static readonly TimeSpan MinExpirationTime = TimeSpan.FromSeconds(10.0);
95 95
96 /// <summary> 96 /// <summary>
97 /// Comparer used to compare element keys. 97 /// Comparer used to compare element keys.
@@ -171,7 +171,7 @@ namespace OpenSim.Framework
171 /// Initializes a new instance of the <see cref="CnmMemoryCache{TKey,TValue}"/> class. 171 /// Initializes a new instance of the <see cref="CnmMemoryCache{TKey,TValue}"/> class.
172 /// </summary> 172 /// </summary>
173 public CnmMemoryCache() 173 public CnmMemoryCache()
174 : this( DefaultMaxSize ) 174 : this(DefaultMaxSize)
175 { 175 {
176 } 176 }
177 177
@@ -181,8 +181,8 @@ namespace OpenSim.Framework
181 /// <param name="maximalSize"> 181 /// <param name="maximalSize">
182 /// Maximal cache size. 182 /// Maximal cache size.
183 /// </param> 183 /// </param>
184 public CnmMemoryCache( long maximalSize ) 184 public CnmMemoryCache(long maximalSize)
185 : this( maximalSize, DefaultMaxCount ) 185 : this(maximalSize, DefaultMaxCount)
186 { 186 {
187 } 187 }
188 188
@@ -195,8 +195,8 @@ namespace OpenSim.Framework
195 /// <param name="maximalCount"> 195 /// <param name="maximalCount">
196 /// Maximal element count. 196 /// Maximal element count.
197 /// </param> 197 /// </param>
198 public CnmMemoryCache( long maximalSize, int maximalCount ) 198 public CnmMemoryCache(long maximalSize, int maximalCount)
199 : this( maximalSize, maximalCount, DefaultExpirationTime ) 199 : this(maximalSize, maximalCount, DefaultExpirationTime)
200 { 200 {
201 } 201 }
202 202
@@ -212,8 +212,8 @@ namespace OpenSim.Framework
212 /// <param name="expirationTime"> 212 /// <param name="expirationTime">
213 /// Elements expiration time. 213 /// Elements expiration time.
214 /// </param> 214 /// </param>
215 public CnmMemoryCache( long maximalSize, int maximalCount, TimeSpan expirationTime ) 215 public CnmMemoryCache(long maximalSize, int maximalCount, TimeSpan expirationTime)
216 : this( maximalSize, maximalCount, expirationTime, EqualityComparer<TKey>.Default ) 216 : this(maximalSize, maximalCount, expirationTime, EqualityComparer<TKey>.Default)
217 { 217 {
218 } 218 }
219 219
@@ -235,21 +235,21 @@ namespace OpenSim.Framework
235 /// <exception cref="ArgumentNullException"> 235 /// <exception cref="ArgumentNullException">
236 /// <see cref="comparer"/>is <see langword="null"/> reference. 236 /// <see cref="comparer"/>is <see langword="null"/> reference.
237 /// </exception> 237 /// </exception>
238 public CnmMemoryCache( long maximalSize, 238 public CnmMemoryCache(long maximalSize,
239 int maximalCount, 239 int maximalCount,
240 TimeSpan expirationTime, 240 TimeSpan expirationTime,
241 IEqualityComparer<TKey> comparer ) 241 IEqualityComparer<TKey> comparer)
242 { 242 {
243 if( comparer == null ) 243 if (comparer == null)
244 throw new ArgumentNullException( "comparer" ); 244 throw new ArgumentNullException("comparer");
245 245
246 if( expirationTime < MinExpirationTime ) 246 if (expirationTime < MinExpirationTime)
247 expirationTime = MinExpirationTime; 247 expirationTime = MinExpirationTime;
248 if( maximalCount < 8 ) 248 if (maximalCount < 8)
249 maximalCount = 8; 249 maximalCount = 8;
250 if( maximalSize < 8 ) 250 if (maximalSize < 8)
251 maximalSize = 8; 251 maximalSize = 8;
252 if( maximalCount > maximalSize ) 252 if (maximalCount > maximalSize)
253 maximalCount = (int) maximalSize; 253 maximalCount = (int) maximalSize;
254 254
255 Comparer = comparer; 255 Comparer = comparer;
@@ -275,14 +275,14 @@ namespace OpenSim.Framework
275 /// <param name="size"> 275 /// <param name="size">
276 /// The element's size. 276 /// The element's size.
277 /// </param> 277 /// </param>
278 protected virtual void AddToNewGeneration( int bucketIndex, TKey key, TValue value, long size ) 278 protected virtual void AddToNewGeneration(int bucketIndex, TKey key, TValue value, long size)
279 { 279 {
280 // Add to newest generation 280 // Add to newest generation
281 if( !m_newGeneration.Set( bucketIndex, key, value, size ) ) 281 if (!m_newGeneration.Set(bucketIndex, key, value, size))
282 { 282 {
283 // Failed to add new generation 283 // Failed to add new generation
284 RecycleGenerations(); 284 RecycleGenerations();
285 m_newGeneration.Set( bucketIndex, key, value, size ); 285 m_newGeneration.Set(bucketIndex, key, value, size);
286 } 286 }
287 287
288 m_version++; 288 m_version++;
@@ -314,9 +314,9 @@ namespace OpenSim.Framework
314 /// For example: key's hash is 72, bucket count is 5, element's bucket index is 72 % 5 = 2. 314 /// For example: key's hash is 72, bucket count is 5, element's bucket index is 72 % 5 = 2.
315 /// </para> 315 /// </para>
316 /// </remarks> 316 /// </remarks>
317 protected virtual int GetBucketIndex( TKey key ) 317 protected virtual int GetBucketIndex(TKey key)
318 { 318 {
319 return (Comparer.GetHashCode( key ) & 0x7FFFFFFF) % m_generationBucketCount; 319 return (Comparer.GetHashCode(key) & 0x7FFFFFFF) % m_generationBucketCount;
320 } 320 }
321 321
322 /// <summary> 322 /// <summary>
@@ -325,7 +325,7 @@ namespace OpenSim.Framework
325 /// <param name="generation"> 325 /// <param name="generation">
326 /// The generation that is purged. 326 /// The generation that is purged.
327 /// </param> 327 /// </param>
328 protected virtual void PurgeGeneration( IGeneration generation ) 328 protected virtual void PurgeGeneration(IGeneration generation)
329 { 329 {
330 generation.Clear(); 330 generation.Clear();
331 m_version++; 331 m_version++;
@@ -339,7 +339,7 @@ namespace OpenSim.Framework
339 // Do this only one in every m_operationsBetweenTimeChecks 339 // Do this only one in every m_operationsBetweenTimeChecks
340 // Fetching time is using several millisecons - it is better not to do all time. 340 // Fetching time is using several millisecons - it is better not to do all time.
341 m_operationsBetweenTimeChecks--; 341 m_operationsBetweenTimeChecks--;
342 if( m_operationsBetweenTimeChecks <= 0 ) 342 if (m_operationsBetweenTimeChecks <= 0)
343 PurgeExpired(); 343 PurgeExpired();
344 } 344 }
345 345
@@ -355,10 +355,10 @@ namespace OpenSim.Framework
355 m_generationElementCount = MaxCount / 2; 355 m_generationElementCount = MaxCount / 2;
356 356
357 // Buckets need to be prime number to get better spread of hash values 357 // Buckets need to be prime number to get better spread of hash values
358 m_generationBucketCount = PrimeNumberHelper.GetPrime( m_generationElementCount ); 358 m_generationBucketCount = PrimeNumberHelper.GetPrime(m_generationElementCount);
359 359
360 m_newGeneration = new HashGeneration( this ); 360 m_newGeneration = new HashGeneration(this);
361 m_oldGeneration = new HashGeneration( this ); 361 m_oldGeneration = new HashGeneration(this);
362 m_oldGeneration.MakeOld(); 362 m_oldGeneration.MakeOld();
363 } 363 }
364 364
@@ -399,7 +399,7 @@ namespace OpenSim.Framework
399 /// <param name="cache"> 399 /// <param name="cache">
400 /// The cache. 400 /// The cache.
401 /// </param> 401 /// </param>
402 public Enumerator( CnmMemoryCache<TKey, TValue> cache ) 402 public Enumerator(CnmMemoryCache<TKey, TValue> cache)
403 { 403 {
404 m_generationEnumerators[ 0 ] = cache.m_newGeneration.GetEnumerator(); 404 m_generationEnumerators[ 0 ] = cache.m_newGeneration.GetEnumerator();
405 m_generationEnumerators[ 1 ] = cache.m_oldGeneration.GetEnumerator(); 405 m_generationEnumerators[ 1 ] = cache.m_oldGeneration.GetEnumerator();
@@ -420,7 +420,7 @@ namespace OpenSim.Framework
420 { 420 {
421 get 421 get
422 { 422 {
423 if( m_currentEnumerator == -1 || m_currentEnumerator >= m_generationEnumerators.Length ) 423 if (m_currentEnumerator == -1 || m_currentEnumerator >= m_generationEnumerators.Length)
424 throw new InvalidOperationException(); 424 throw new InvalidOperationException();
425 425
426 return m_generationEnumerators[ m_currentEnumerator ].Current; 426 return m_generationEnumerators[ m_currentEnumerator ].Current;
@@ -461,12 +461,12 @@ namespace OpenSim.Framework
461 /// <filterpriority>2</filterpriority> 461 /// <filterpriority>2</filterpriority>
462 public bool MoveNext() 462 public bool MoveNext()
463 { 463 {
464 if( m_currentEnumerator == -1 ) 464 if (m_currentEnumerator == -1)
465 m_currentEnumerator = 0; 465 m_currentEnumerator = 0;
466 466
467 while( m_currentEnumerator < m_generationEnumerators.Length ) 467 while (m_currentEnumerator < m_generationEnumerators.Length)
468 { 468 {
469 if( m_generationEnumerators[ m_currentEnumerator ].MoveNext() ) 469 if (m_generationEnumerators[ m_currentEnumerator ].MoveNext())
470 return true; 470 return true;
471 471
472 m_currentEnumerator++; 472 m_currentEnumerator++;
@@ -484,7 +484,7 @@ namespace OpenSim.Framework
484 /// <filterpriority>2</filterpriority> 484 /// <filterpriority>2</filterpriority>
485 public void Reset() 485 public void Reset()
486 { 486 {
487 foreach( IEnumerator<KeyValuePair<TKey, TValue>> enumerator in m_generationEnumerators ) 487 foreach (IEnumerator<KeyValuePair<TKey, TValue>> enumerator in m_generationEnumerators)
488 { 488 {
489 enumerator.Reset(); 489 enumerator.Reset();
490 } 490 }
@@ -582,7 +582,7 @@ namespace OpenSim.Framework
582 /// <param name="cache"> 582 /// <param name="cache">
583 /// The cache. 583 /// The cache.
584 /// </param> 584 /// </param>
585 public HashGeneration( CnmMemoryCache<TKey, TValue> cache ) 585 public HashGeneration(CnmMemoryCache<TKey, TValue> cache)
586 { 586 {
587 m_cache = cache; 587 m_cache = cache;
588 m_elements = new Element[m_cache.m_generationElementCount]; 588 m_elements = new Element[m_cache.m_generationElementCount];
@@ -608,16 +608,16 @@ namespace OpenSim.Framework
608 /// <returns> 608 /// <returns>
609 /// Element's index, if found from the generation; -1 otherwise (if element is not found the generation). 609 /// Element's index, if found from the generation; -1 otherwise (if element is not found the generation).
610 /// </returns> 610 /// </returns>
611 private int FindElementIndex( int bucketIndex, TKey key, bool moveToFront, out int previousIndex ) 611 private int FindElementIndex(int bucketIndex, TKey key, bool moveToFront, out int previousIndex)
612 { 612 {
613 previousIndex = -1; 613 previousIndex = -1;
614 int elementIndex = m_buckets[ bucketIndex ]; 614 int elementIndex = m_buckets[ bucketIndex ];
615 while( elementIndex >= 0 ) 615 while (elementIndex >= 0)
616 { 616 {
617 if( m_cache.Comparer.Equals( key, m_elements[ elementIndex ].Key ) ) 617 if (m_cache.Comparer.Equals(key, m_elements[ elementIndex ].Key))
618 { 618 {
619 // Found match 619 // Found match
620 if( moveToFront && previousIndex >= 0 ) 620 if (moveToFront && previousIndex >= 0)
621 { 621 {
622 // Move entry to front 622 // Move entry to front
623 m_elements[ previousIndex ].Next = m_elements[ elementIndex ].Next; 623 m_elements[ previousIndex ].Next = m_elements[ elementIndex ].Next;
@@ -648,9 +648,9 @@ namespace OpenSim.Framework
648 /// <param name="previousIndex"> 648 /// <param name="previousIndex">
649 /// The element's previous index. 649 /// The element's previous index.
650 /// </param> 650 /// </param>
651 private void RemoveElement( int bucketIndex, int entryIndex, int previousIndex ) 651 private void RemoveElement(int bucketIndex, int entryIndex, int previousIndex)
652 { 652 {
653 if( previousIndex >= 0 ) 653 if (previousIndex >= 0)
654 m_elements[ previousIndex ].Next = m_elements[ entryIndex ].Next; 654 m_elements[ previousIndex ].Next = m_elements[ entryIndex ].Next;
655 else 655 else
656 m_buckets[ bucketIndex ] = m_elements[ entryIndex ].Next; 656 m_buckets[ bucketIndex ] = m_elements[ entryIndex ].Next;
@@ -755,7 +755,7 @@ namespace OpenSim.Framework
755 /// <param name="generation"> 755 /// <param name="generation">
756 /// The generation. 756 /// The generation.
757 /// </param> 757 /// </param>
758 public Enumerator( HashGeneration generation ) 758 public Enumerator(HashGeneration generation)
759 { 759 {
760 m_generation = generation; 760 m_generation = generation;
761 m_version = m_generation.m_cache.m_version; 761 m_version = m_generation.m_cache.m_version;
@@ -776,7 +776,7 @@ namespace OpenSim.Framework
776 { 776 {
777 get 777 get
778 { 778 {
779 if( m_currentIndex == 0 || m_currentIndex >= m_generation.Count ) 779 if (m_currentIndex == 0 || m_currentIndex >= m_generation.Count)
780 throw new InvalidOperationException(); 780 throw new InvalidOperationException();
781 781
782 return m_current; 782 return m_current;
@@ -816,19 +816,19 @@ namespace OpenSim.Framework
816 /// </exception> 816 /// </exception>
817 public bool MoveNext() 817 public bool MoveNext()
818 { 818 {
819 if( m_version != m_generation.m_cache.m_version ) 819 if (m_version != m_generation.m_cache.m_version)
820 throw new InvalidOperationException(); 820 throw new InvalidOperationException();
821 821
822 while( m_currentIndex < m_generation.Count ) 822 while (m_currentIndex < m_generation.Count)
823 { 823 {
824 if( m_generation.m_elements[ m_currentIndex ].IsFree ) 824 if (m_generation.m_elements[ m_currentIndex ].IsFree)
825 { 825 {
826 m_currentIndex++; 826 m_currentIndex++;
827 continue; 827 continue;
828 } 828 }
829 829
830 m_current = new KeyValuePair<TKey, TValue>( m_generation.m_elements[ m_currentIndex ].Key, 830 m_current = new KeyValuePair<TKey, TValue>(m_generation.m_elements[ m_currentIndex ].Key,
831 m_generation.m_elements[ m_currentIndex ].Value ); 831 m_generation.m_elements[ m_currentIndex ].Value);
832 m_currentIndex++; 832 m_currentIndex++;
833 return true; 833 return true;
834 } 834 }
@@ -846,7 +846,7 @@ namespace OpenSim.Framework
846 /// <filterpriority>2</filterpriority> 846 /// <filterpriority>2</filterpriority>
847 public void Reset() 847 public void Reset()
848 { 848 {
849 if( m_version != m_generation.m_cache.m_version ) 849 if (m_version != m_generation.m_cache.m_version)
850 throw new InvalidOperationException(); 850 throw new InvalidOperationException();
851 851
852 m_currentIndex = 0; 852 m_currentIndex = 0;
@@ -907,12 +907,12 @@ namespace OpenSim.Framework
907 /// <seealso cref="IGeneration.MakeOld"/> 907 /// <seealso cref="IGeneration.MakeOld"/>
908 public void Clear() 908 public void Clear()
909 { 909 {
910 for( int i = m_buckets.Length - 1 ; i >= 0 ; i-- ) 910 for (int i = m_buckets.Length - 1 ; i >= 0 ; i--)
911 { 911 {
912 m_buckets[ i ] = -1; 912 m_buckets[ i ] = -1;
913 } 913 }
914 914
915 Array.Clear( m_elements, 0, m_elements.Length ); 915 Array.Clear(m_elements, 0, m_elements.Length);
916 Size = 0; 916 Size = 0;
917 m_firstFreeElement = -1; 917 m_firstFreeElement = -1;
918 m_freeCount = 0; 918 m_freeCount = 0;
@@ -934,10 +934,10 @@ namespace OpenSim.Framework
934 /// <see langword="true"/>if the <see cref="IGeneration"/> contains an element with the <see cref="key"/>; 934 /// <see langword="true"/>if the <see cref="IGeneration"/> contains an element with the <see cref="key"/>;
935 /// otherwise <see langword="false"/>. 935 /// otherwise <see langword="false"/>.
936 /// </returns> 936 /// </returns>
937 public bool Contains( int bucketIndex, TKey key ) 937 public bool Contains(int bucketIndex, TKey key)
938 { 938 {
939 int previousIndex; 939 int previousIndex;
940 if( FindElementIndex( bucketIndex, key, true, out previousIndex ) == -1 ) 940 if (FindElementIndex(bucketIndex, key, true, out previousIndex) == -1)
941 return false; 941 return false;
942 942
943 AccessedSinceLastTimeCheck = true; 943 AccessedSinceLastTimeCheck = true;
@@ -953,7 +953,7 @@ namespace OpenSim.Framework
953 /// <filterpriority>1</filterpriority> 953 /// <filterpriority>1</filterpriority>
954 public IEnumerator<KeyValuePair<TKey, TValue>> GetEnumerator() 954 public IEnumerator<KeyValuePair<TKey, TValue>> GetEnumerator()
955 { 955 {
956 return new Enumerator( this ); 956 return new Enumerator(this);
957 } 957 }
958 958
959 /// <summary> 959 /// <summary>
@@ -980,13 +980,13 @@ namespace OpenSim.Framework
980 /// <returns> 980 /// <returns>
981 /// <see langword="true"/>, if remove was successful; otherwise <see langword="false"/>. 981 /// <see langword="true"/>, if remove was successful; otherwise <see langword="false"/>.
982 /// </returns> 982 /// </returns>
983 public bool Remove( int bucketIndex, TKey key ) 983 public bool Remove(int bucketIndex, TKey key)
984 { 984 {
985 int previousIndex; 985 int previousIndex;
986 int entryIndex = FindElementIndex( bucketIndex, key, false, out previousIndex ); 986 int entryIndex = FindElementIndex(bucketIndex, key, false, out previousIndex);
987 if( entryIndex != -1 ) 987 if (entryIndex != -1)
988 { 988 {
989 RemoveElement( bucketIndex, entryIndex, previousIndex ); 989 RemoveElement(bucketIndex, entryIndex, previousIndex);
990 AccessedSinceLastTimeCheck = true; 990 AccessedSinceLastTimeCheck = true;
991 return true; 991 return true;
992 } 992 }
@@ -1020,18 +1020,18 @@ namespace OpenSim.Framework
1020 /// size must fit generation's limits, before element is added to generation. 1020 /// size must fit generation's limits, before element is added to generation.
1021 /// </para> 1021 /// </para>
1022 /// </remarks> 1022 /// </remarks>
1023 public bool Set( int bucketIndex, TKey key, TValue value, long size ) 1023 public bool Set(int bucketIndex, TKey key, TValue value, long size)
1024 { 1024 {
1025 Debug.Assert( m_newGeneration, "It is possible to insert new elements only to newest generation." ); 1025 Debug.Assert(m_newGeneration, "It is possible to insert new elements only to newest generation.");
1026 Debug.Assert( size > 0, "New element size should be more than 0." ); 1026 Debug.Assert(size > 0, "New element size should be more than 0.");
1027 1027
1028 int previousIndex; 1028 int previousIndex;
1029 int elementIndex = FindElementIndex( bucketIndex, key, true, out previousIndex ); 1029 int elementIndex = FindElementIndex(bucketIndex, key, true, out previousIndex);
1030 if( elementIndex == -1 ) 1030 if (elementIndex == -1)
1031 { 1031 {
1032 // New key 1032 // New key
1033 if( Size + size > m_cache.m_generationMaxSize || 1033 if (Size + size > m_cache.m_generationMaxSize ||
1034 (m_nextUnusedElement == m_cache.m_generationElementCount && m_freeCount == 0) ) 1034 (m_nextUnusedElement == m_cache.m_generationElementCount && m_freeCount == 0))
1035 { 1035 {
1036 // Generation is full 1036 // Generation is full
1037 return false; 1037 return false;
@@ -1041,7 +1041,7 @@ namespace OpenSim.Framework
1041 Size += size; 1041 Size += size;
1042 1042
1043 // Get first free entry and update free entry list 1043 // Get first free entry and update free entry list
1044 if( m_firstFreeElement != -1 ) 1044 if (m_firstFreeElement != -1)
1045 { 1045 {
1046 // There was entry that was removed 1046 // There was entry that was removed
1047 elementIndex = m_firstFreeElement; 1047 elementIndex = m_firstFreeElement;
@@ -1055,7 +1055,7 @@ namespace OpenSim.Framework
1055 m_nextUnusedElement++; 1055 m_nextUnusedElement++;
1056 } 1056 }
1057 1057
1058 Debug.Assert( m_elements[ elementIndex ].IsFree, "Allocated element is not free." ); 1058 Debug.Assert(m_elements[ elementIndex ].IsFree, "Allocated element is not free.");
1059 1059
1060 // Move new entry to front 1060 // Move new entry to front
1061 m_elements[ elementIndex ].Next = m_buckets[ bucketIndex ]; 1061 m_elements[ elementIndex ].Next = m_buckets[ bucketIndex ];
@@ -1067,12 +1067,12 @@ namespace OpenSim.Framework
1067 else 1067 else
1068 { 1068 {
1069 // Existing key 1069 // Existing key
1070 if( Size - m_elements[ elementIndex ].Size + size > m_cache.m_generationMaxSize ) 1070 if (Size - m_elements[ elementIndex ].Size + size > m_cache.m_generationMaxSize)
1071 { 1071 {
1072 // Generation is full 1072 // Generation is full
1073 // Remove existing element, because generation is going to be recycled to 1073 // Remove existing element, because generation is going to be recycled to
1074 // old generation and element is stored to new generation 1074 // old generation and element is stored to new generation
1075 RemoveElement( bucketIndex, elementIndex, previousIndex ); 1075 RemoveElement(bucketIndex, elementIndex, previousIndex);
1076 return false; 1076 return false;
1077 } 1077 }
1078 1078
@@ -1113,12 +1113,12 @@ namespace OpenSim.Framework
1113 /// are set to default value (default(TValue) and 0). 1113 /// are set to default value (default(TValue) and 0).
1114 /// </para> 1114 /// </para>
1115 /// </remarks> 1115 /// </remarks>
1116 public bool TryGetValue( int bucketIndex, TKey key, out TValue value, out long size ) 1116 public bool TryGetValue(int bucketIndex, TKey key, out TValue value, out long size)
1117 { 1117 {
1118 // Find entry index, 1118 // Find entry index,
1119 int previousIndex; 1119 int previousIndex;
1120 int elementIndex = FindElementIndex( bucketIndex, key, m_newGeneration, out previousIndex ); 1120 int elementIndex = FindElementIndex(bucketIndex, key, m_newGeneration, out previousIndex);
1121 if( elementIndex == -1 ) 1121 if (elementIndex == -1)
1122 { 1122 {
1123 value = default(TValue); 1123 value = default(TValue);
1124 size = 0; 1124 size = 0;
@@ -1128,10 +1128,10 @@ namespace OpenSim.Framework
1128 value = m_elements[ elementIndex ].Value; 1128 value = m_elements[ elementIndex ].Value;
1129 size = m_elements[ elementIndex ].Size; 1129 size = m_elements[ elementIndex ].Size;
1130 1130
1131 if( !m_newGeneration ) 1131 if (!m_newGeneration)
1132 { 1132 {
1133 // Old generation - remove element, because it is moved to new generation 1133 // Old generation - remove element, because it is moved to new generation
1134 RemoveElement( bucketIndex, elementIndex, previousIndex ); 1134 RemoveElement(bucketIndex, elementIndex, previousIndex);
1135 } 1135 }
1136 1136
1137 AccessedSinceLastTimeCheck = true; 1137 AccessedSinceLastTimeCheck = true;
@@ -1214,7 +1214,7 @@ namespace OpenSim.Framework
1214 /// <see langword="true"/>if the <see cref="IGeneration"/> contains an element with the <see cref="key"/>; 1214 /// <see langword="true"/>if the <see cref="IGeneration"/> contains an element with the <see cref="key"/>;
1215 /// otherwise <see langword="false"/>. 1215 /// otherwise <see langword="false"/>.
1216 /// </returns> 1216 /// </returns>
1217 bool Contains( int bucketIndex, TKey key ); 1217 bool Contains(int bucketIndex, TKey key);
1218 1218
1219 /// <summary> 1219 /// <summary>
1220 /// Make from generation old generation. 1220 /// Make from generation old generation.
@@ -1237,7 +1237,7 @@ namespace OpenSim.Framework
1237 /// <returns> 1237 /// <returns>
1238 /// <see langword="true"/>, if remove was successful; otherwise <see langword="false"/>. 1238 /// <see langword="true"/>, if remove was successful; otherwise <see langword="false"/>.
1239 /// </returns> 1239 /// </returns>
1240 bool Remove( int bucketIndex, TKey key ); 1240 bool Remove(int bucketIndex, TKey key);
1241 1241
1242 /// <summary> 1242 /// <summary>
1243 /// Set or add element to generation. 1243 /// Set or add element to generation.
@@ -1265,7 +1265,7 @@ namespace OpenSim.Framework
1265 /// size must fit generation's limits, before element is added to generation. 1265 /// size must fit generation's limits, before element is added to generation.
1266 /// </para> 1266 /// </para>
1267 /// </remarks> 1267 /// </remarks>
1268 bool Set( int bucketIndex, TKey key, TValue value, long size ); 1268 bool Set(int bucketIndex, TKey key, TValue value, long size);
1269 1269
1270 /// <summary> 1270 /// <summary>
1271 /// Try to get element associated with key. 1271 /// Try to get element associated with key.
@@ -1291,7 +1291,7 @@ namespace OpenSim.Framework
1291 /// are set to default value (default(TValue) and 0). 1291 /// are set to default value (default(TValue) and 0).
1292 /// </para> 1292 /// </para>
1293 /// </remarks> 1293 /// </remarks>
1294 bool TryGetValue( int bucketIndex, TKey key, out TValue value, out long size ); 1294 bool TryGetValue(int bucketIndex, TKey key, out TValue value, out long size);
1295 } 1295 }
1296 1296
1297 #endregion 1297 #endregion
@@ -1357,10 +1357,10 @@ namespace OpenSim.Framework
1357 1357
1358 set 1358 set
1359 { 1359 {
1360 if( value < MinExpirationTime ) 1360 if (value < MinExpirationTime)
1361 value = MinExpirationTime; 1361 value = MinExpirationTime;
1362 1362
1363 if( m_expirationTime == value ) 1363 if (m_expirationTime == value)
1364 return; 1364 return;
1365 1365
1366 m_newGeneration.ExpirationTime = (m_newGeneration.ExpirationTime - m_expirationTime) + value; 1366 m_newGeneration.ExpirationTime = (m_newGeneration.ExpirationTime - m_expirationTime) + value;
@@ -1478,9 +1478,9 @@ namespace OpenSim.Framework
1478 1478
1479 set 1479 set
1480 { 1480 {
1481 if( value < 8 ) 1481 if (value < 8)
1482 value = 8; 1482 value = 8;
1483 if( m_maxCount == value ) 1483 if (m_maxCount == value)
1484 return; 1484 return;
1485 1485
1486 m_maxCount = value; 1486 m_maxCount = value;
@@ -1535,9 +1535,9 @@ namespace OpenSim.Framework
1535 1535
1536 set 1536 set
1537 { 1537 {
1538 if( value < 8 ) 1538 if (value < 8)
1539 value = 8; 1539 value = 8;
1540 if( m_maxSize == value ) 1540 if (m_maxSize == value)
1541 return; 1541 return;
1542 1542
1543 m_maxSize = value; 1543 m_maxSize = value;
@@ -1618,7 +1618,7 @@ namespace OpenSim.Framework
1618 /// <filterpriority>1</filterpriority> 1618 /// <filterpriority>1</filterpriority>
1619 public IEnumerator<KeyValuePair<TKey, TValue>> GetEnumerator() 1619 public IEnumerator<KeyValuePair<TKey, TValue>> GetEnumerator()
1620 { 1620 {
1621 return new Enumerator( this ); 1621 return new Enumerator(this);
1622 } 1622 }
1623 1623
1624 /// <summary> 1624 /// <summary>
@@ -1644,28 +1644,28 @@ namespace OpenSim.Framework
1644 { 1644 {
1645 m_operationsBetweenTimeChecks = DefaultOperationsBetweenTimeChecks; 1645 m_operationsBetweenTimeChecks = DefaultOperationsBetweenTimeChecks;
1646 1646
1647 if( !IsTimeLimited ) 1647 if (!IsTimeLimited)
1648 return; 1648 return;
1649 1649
1650 DateTime now = DateTime.Now; 1650 DateTime now = DateTime.Now;
1651 if( m_newGeneration.AccessedSinceLastTimeCheck ) 1651 if (m_newGeneration.AccessedSinceLastTimeCheck)
1652 { 1652 {
1653 // New generation has been accessed since last check 1653 // New generation has been accessed since last check
1654 // Update it's expiration time. 1654 // Update it's expiration time.
1655 m_newGeneration.ExpirationTime = now + ExpirationTime; 1655 m_newGeneration.ExpirationTime = now + ExpirationTime;
1656 m_newGeneration.AccessedSinceLastTimeCheck = false; 1656 m_newGeneration.AccessedSinceLastTimeCheck = false;
1657 } 1657 }
1658 else if( m_newGeneration.ExpirationTime < now ) 1658 else if (m_newGeneration.ExpirationTime < now)
1659 { 1659 {
1660 // New generation has been expired. 1660 // New generation has been expired.
1661 // --> also old generation must be expired. 1661 // --> also old generation must be expired.
1662 PurgeGeneration( m_newGeneration ); 1662 PurgeGeneration(m_newGeneration);
1663 PurgeGeneration( m_oldGeneration ); 1663 PurgeGeneration(m_oldGeneration);
1664 return; 1664 return;
1665 } 1665 }
1666 1666
1667 if( m_oldGeneration.ExpirationTime < now ) 1667 if (m_oldGeneration.ExpirationTime < now)
1668 PurgeGeneration( m_oldGeneration ); 1668 PurgeGeneration(m_oldGeneration);
1669 } 1669 }
1670 1670
1671 /// <summary> 1671 /// <summary>
@@ -1682,15 +1682,15 @@ namespace OpenSim.Framework
1682 /// <seealso cref="ICnmCache{TKey,TValue}.TryGetValue"/> 1682 /// <seealso cref="ICnmCache{TKey,TValue}.TryGetValue"/>
1683 /// <seealso cref="ICnmCache{TKey,TValue}.Clear"/> 1683 /// <seealso cref="ICnmCache{TKey,TValue}.Clear"/>
1684 /// <seealso cref="ICnmCache{TKey,TValue}.PurgeExpired"/> 1684 /// <seealso cref="ICnmCache{TKey,TValue}.PurgeExpired"/>
1685 public void Remove( TKey key ) 1685 public void Remove(TKey key)
1686 { 1686 {
1687 if( key == null ) 1687 if (key == null)
1688 throw new ArgumentNullException( "key" ); 1688 throw new ArgumentNullException("key");
1689 1689
1690 int bucketIndex = GetBucketIndex( key ); 1690 int bucketIndex = GetBucketIndex(key);
1691 if( !m_newGeneration.Remove( bucketIndex, key ) ) 1691 if (!m_newGeneration.Remove(bucketIndex, key))
1692 { 1692 {
1693 if( !m_oldGeneration.Remove( bucketIndex, key ) ) 1693 if (!m_oldGeneration.Remove(bucketIndex, key))
1694 { 1694 {
1695 CheckExpired(); 1695 CheckExpired();
1696 return; 1696 return;
@@ -1715,19 +1715,19 @@ namespace OpenSim.Framework
1715 /// <seealso cref="ICnmCache{TKey,TValue}.TryGetValue"/> 1715 /// <seealso cref="ICnmCache{TKey,TValue}.TryGetValue"/>
1716 /// <seealso cref="ICnmCache{TKey,TValue}.Clear"/> 1716 /// <seealso cref="ICnmCache{TKey,TValue}.Clear"/>
1717 /// <seealso cref="ICnmCache{TKey,TValue}.PurgeExpired"/> 1717 /// <seealso cref="ICnmCache{TKey,TValue}.PurgeExpired"/>
1718 public void RemoveRange( IEnumerable<TKey> keys ) 1718 public void RemoveRange(IEnumerable<TKey> keys)
1719 { 1719 {
1720 if( keys == null ) 1720 if (keys == null)
1721 throw new ArgumentNullException( "keys" ); 1721 throw new ArgumentNullException("keys");
1722 1722
1723 foreach( TKey key in keys ) 1723 foreach (TKey key in keys)
1724 { 1724 {
1725 if( key == null ) 1725 if (key == null)
1726 continue; 1726 continue;
1727 1727
1728 int bucketIndex = GetBucketIndex( key ); 1728 int bucketIndex = GetBucketIndex(key);
1729 if( !m_newGeneration.Remove( bucketIndex, key ) ) 1729 if (!m_newGeneration.Remove(bucketIndex, key))
1730 m_oldGeneration.Remove( bucketIndex, key ); 1730 m_oldGeneration.Remove(bucketIndex, key);
1731 } 1731 }
1732 1732
1733 CheckExpired(); 1733 CheckExpired();
@@ -1779,27 +1779,27 @@ namespace OpenSim.Framework
1779 /// <seealso cref="ICnmCache{TKey,TValue}.TryGetValue"/> 1779 /// <seealso cref="ICnmCache{TKey,TValue}.TryGetValue"/>
1780 /// <seealso cref="ICnmCache{TKey,TValue}.Clear"/> 1780 /// <seealso cref="ICnmCache{TKey,TValue}.Clear"/>
1781 /// <seealso cref="ICnmCache{TKey,TValue}.PurgeExpired"/> 1781 /// <seealso cref="ICnmCache{TKey,TValue}.PurgeExpired"/>
1782 public bool Set( TKey key, TValue value, long size ) 1782 public bool Set(TKey key, TValue value, long size)
1783 { 1783 {
1784 if( key == null ) 1784 if (key == null)
1785 throw new ArgumentNullException( "key" ); 1785 throw new ArgumentNullException("key");
1786 1786
1787 if( size < 0 ) 1787 if (size < 0)
1788 throw new ArgumentOutOfRangeException( "size", size, "Value's size can't be less than 0." ); 1788 throw new ArgumentOutOfRangeException("size", size, "Value's size can't be less than 0.");
1789 1789
1790 if( size > MaxElementSize ) 1790 if (size > MaxElementSize)
1791 { 1791 {
1792 // Entry size is too big to fit cache - ignore it 1792 // Entry size is too big to fit cache - ignore it
1793 Remove( key ); 1793 Remove(key);
1794 return false; 1794 return false;
1795 } 1795 }
1796 1796
1797 if( size == 0 ) 1797 if (size == 0)
1798 size = 1; 1798 size = 1;
1799 1799
1800 int bucketIndex = GetBucketIndex( key ); 1800 int bucketIndex = GetBucketIndex(key);
1801 m_oldGeneration.Remove( bucketIndex, key ); 1801 m_oldGeneration.Remove(bucketIndex, key);
1802 AddToNewGeneration( bucketIndex, key, value, size ); 1802 AddToNewGeneration(bucketIndex, key, value, size);
1803 CheckExpired(); 1803 CheckExpired();
1804 1804
1805 return true; 1805 return true;
@@ -1828,23 +1828,23 @@ namespace OpenSim.Framework
1828 /// <seealso cref="ICnmCache{TKey,TValue}.RemoveRange"/> 1828 /// <seealso cref="ICnmCache{TKey,TValue}.RemoveRange"/>
1829 /// <seealso cref="ICnmCache{TKey,TValue}.Clear"/> 1829 /// <seealso cref="ICnmCache{TKey,TValue}.Clear"/>
1830 /// <seealso cref="ICnmCache{TKey,TValue}.PurgeExpired"/> 1830 /// <seealso cref="ICnmCache{TKey,TValue}.PurgeExpired"/>
1831 public bool TryGetValue( TKey key, out TValue value ) 1831 public bool TryGetValue(TKey key, out TValue value)
1832 { 1832 {
1833 if( key == null ) 1833 if (key == null)
1834 throw new ArgumentNullException( "key" ); 1834 throw new ArgumentNullException("key");
1835 1835
1836 int bucketIndex = GetBucketIndex( key ); 1836 int bucketIndex = GetBucketIndex(key);
1837 long size; 1837 long size;
1838 if( m_newGeneration.TryGetValue( bucketIndex, key, out value, out size ) ) 1838 if (m_newGeneration.TryGetValue(bucketIndex, key, out value, out size))
1839 { 1839 {
1840 CheckExpired(); 1840 CheckExpired();
1841 return true; 1841 return true;
1842 } 1842 }
1843 1843
1844 if( m_oldGeneration.TryGetValue( bucketIndex, key, out value, out size ) ) 1844 if (m_oldGeneration.TryGetValue(bucketIndex, key, out value, out size))
1845 { 1845 {
1846 // Move element to new generation 1846 // Move element to new generation
1847 AddToNewGeneration( bucketIndex, key, value, size ); 1847 AddToNewGeneration(bucketIndex, key, value, size);
1848 CheckExpired(); 1848 CheckExpired();
1849 return true; 1849 return true;
1850 } 1850 }
diff --git a/OpenSim/Framework/CnmSynchronizedCache.cs b/OpenSim/Framework/CnmSynchronizedCache.cs
index bf588ce..c09900e 100644
--- a/OpenSim/Framework/CnmSynchronizedCache.cs
+++ b/OpenSim/Framework/CnmSynchronizedCache.cs
@@ -24,6 +24,7 @@
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */ 26 */
27
27using System; 28using System;
28using System.Collections; 29using System.Collections;
29using System.Collections.Generic; 30using System.Collections.Generic;
@@ -65,7 +66,7 @@ namespace OpenSim.Framework
65 /// <param name="cache"> 66 /// <param name="cache">
66 /// The cache. 67 /// The cache.
67 /// </param> 68 /// </param>
68 private CnmSynchronizedCache( ICnmCache<TKey, TValue> cache ) 69 private CnmSynchronizedCache(ICnmCache<TKey, TValue> cache)
69 { 70 {
70 m_cache = cache; 71 m_cache = cache;
71 m_syncRoot = m_cache.SyncRoot; 72 m_syncRoot = m_cache.SyncRoot;
@@ -83,11 +84,11 @@ namespace OpenSim.Framework
83 /// <exception cref="ArgumentNullException"> 84 /// <exception cref="ArgumentNullException">
84 /// <paramref name="cache"/>is null. 85 /// <paramref name="cache"/>is null.
85 /// </exception> 86 /// </exception>
86 public static ICnmCache<TKey, TValue> Synchronized( ICnmCache<TKey, TValue> cache ) 87 public static ICnmCache<TKey, TValue> Synchronized(ICnmCache<TKey, TValue> cache)
87 { 88 {
88 if( cache == null ) 89 if (cache == null)
89 throw new ArgumentNullException( "cache" ); 90 throw new ArgumentNullException("cache");
90 return cache.IsSynchronized ? cache : new CnmSynchronizedCache<TKey, TValue>( cache ); 91 return cache.IsSynchronized ? cache : new CnmSynchronizedCache<TKey, TValue>(cache);
91 } 92 }
92 93
93 #region Nested type: SynchronizedEnumerator 94 #region Nested type: SynchronizedEnumerator
@@ -116,11 +117,11 @@ namespace OpenSim.Framework
116 /// <param name="syncRoot"> 117 /// <param name="syncRoot">
117 /// The sync root. 118 /// The sync root.
118 /// </param> 119 /// </param>
119 public SynchronizedEnumerator( IEnumerator<KeyValuePair<TKey, TValue>> enumerator, object syncRoot ) 120 public SynchronizedEnumerator(IEnumerator<KeyValuePair<TKey, TValue>> enumerator, object syncRoot)
120 { 121 {
121 m_syncRoot = syncRoot; 122 m_syncRoot = syncRoot;
122 m_enumerator = enumerator; 123 m_enumerator = enumerator;
123 Monitor.Enter( m_syncRoot ); 124 Monitor.Enter(m_syncRoot);
124 } 125 }
125 126
126 /// <summary> 127 /// <summary>
@@ -166,14 +167,14 @@ namespace OpenSim.Framework
166 /// </summary> 167 /// </summary>
167 public void Dispose() 168 public void Dispose()
168 { 169 {
169 if( m_syncRoot != null ) 170 if (m_syncRoot != null)
170 { 171 {
171 Monitor.Exit( m_syncRoot ); 172 Monitor.Exit(m_syncRoot);
172 m_syncRoot = null; 173 m_syncRoot = null;
173 } 174 }
174 175
175 m_enumerator.Dispose(); 176 m_enumerator.Dispose();
176 GC.SuppressFinalize( this ); 177 GC.SuppressFinalize(this);
177 } 178 }
178 179
179 /// <summary> 180 /// <summary>
@@ -225,7 +226,7 @@ namespace OpenSim.Framework
225 { 226 {
226 get 227 get
227 { 228 {
228 lock( m_syncRoot ) 229 lock (m_syncRoot)
229 { 230 {
230 return m_cache.Count; 231 return m_cache.Count;
231 } 232 }
@@ -271,7 +272,7 @@ namespace OpenSim.Framework
271 { 272 {
272 get 273 get
273 { 274 {
274 lock( m_syncRoot ) 275 lock (m_syncRoot)
275 { 276 {
276 return m_cache.ExpirationTime; 277 return m_cache.ExpirationTime;
277 } 278 }
@@ -279,7 +280,7 @@ namespace OpenSim.Framework
279 280
280 set 281 set
281 { 282 {
282 lock( m_syncRoot ) 283 lock (m_syncRoot)
283 { 284 {
284 m_cache.ExpirationTime = value; 285 m_cache.ExpirationTime = value;
285 } 286 }
@@ -307,7 +308,7 @@ namespace OpenSim.Framework
307 { 308 {
308 get 309 get
309 { 310 {
310 lock( m_syncRoot ) 311 lock (m_syncRoot)
311 { 312 {
312 return m_cache.IsCountLimited; 313 return m_cache.IsCountLimited;
313 } 314 }
@@ -336,7 +337,7 @@ namespace OpenSim.Framework
336 { 337 {
337 get 338 get
338 { 339 {
339 lock( m_syncRoot ) 340 lock (m_syncRoot)
340 { 341 {
341 return m_cache.IsSizeLimited; 342 return m_cache.IsSizeLimited;
342 } 343 }
@@ -385,7 +386,7 @@ namespace OpenSim.Framework
385 { 386 {
386 get 387 get
387 { 388 {
388 lock( m_syncRoot ) 389 lock (m_syncRoot)
389 { 390 {
390 return m_cache.IsTimeLimited; 391 return m_cache.IsTimeLimited;
391 } 392 }
@@ -409,7 +410,7 @@ namespace OpenSim.Framework
409 { 410 {
410 get 411 get
411 { 412 {
412 lock( m_syncRoot ) 413 lock (m_syncRoot)
413 { 414 {
414 return m_cache.MaxCount; 415 return m_cache.MaxCount;
415 } 416 }
@@ -417,7 +418,7 @@ namespace OpenSim.Framework
417 418
418 set 419 set
419 { 420 {
420 lock( m_syncRoot ) 421 lock (m_syncRoot)
421 { 422 {
422 m_cache.MaxCount = value; 423 m_cache.MaxCount = value;
423 } 424 }
@@ -444,7 +445,7 @@ namespace OpenSim.Framework
444 { 445 {
445 get 446 get
446 { 447 {
447 lock( m_syncRoot ) 448 lock (m_syncRoot)
448 { 449 {
449 return m_cache.MaxElementSize; 450 return m_cache.MaxElementSize;
450 } 451 }
@@ -474,7 +475,7 @@ namespace OpenSim.Framework
474 { 475 {
475 get 476 get
476 { 477 {
477 lock( m_syncRoot ) 478 lock (m_syncRoot)
478 { 479 {
479 return m_cache.MaxSize; 480 return m_cache.MaxSize;
480 } 481 }
@@ -482,7 +483,7 @@ namespace OpenSim.Framework
482 483
483 set 484 set
484 { 485 {
485 lock( m_syncRoot ) 486 lock (m_syncRoot)
486 { 487 {
487 m_cache.MaxSize = value; 488 m_cache.MaxSize = value;
488 } 489 }
@@ -516,7 +517,7 @@ namespace OpenSim.Framework
516 { 517 {
517 get 518 get
518 { 519 {
519 lock( m_syncRoot ) 520 lock (m_syncRoot)
520 { 521 {
521 return m_cache.Size; 522 return m_cache.Size;
522 } 523 }
@@ -553,7 +554,7 @@ namespace OpenSim.Framework
553 /// <seealso cref="ICnmCache{TKey,TValue}.PurgeExpired"/> 554 /// <seealso cref="ICnmCache{TKey,TValue}.PurgeExpired"/>
554 public void Clear() 555 public void Clear()
555 { 556 {
556 lock( m_syncRoot ) 557 lock (m_syncRoot)
557 { 558 {
558 m_cache.Clear(); 559 m_cache.Clear();
559 } 560 }
@@ -568,9 +569,9 @@ namespace OpenSim.Framework
568 /// <filterpriority>1</filterpriority> 569 /// <filterpriority>1</filterpriority>
569 public IEnumerator<KeyValuePair<TKey, TValue>> GetEnumerator() 570 public IEnumerator<KeyValuePair<TKey, TValue>> GetEnumerator()
570 { 571 {
571 lock( m_syncRoot ) 572 lock (m_syncRoot)
572 { 573 {
573 return new SynchronizedEnumerator( m_cache.GetEnumerator(), m_syncRoot ); 574 return new SynchronizedEnumerator(m_cache.GetEnumerator(), m_syncRoot);
574 } 575 }
575 } 576 }
576 577
@@ -595,7 +596,7 @@ namespace OpenSim.Framework
595 /// <seealso cref="ICnmCache{TKey,TValue}.Clear"/> 596 /// <seealso cref="ICnmCache{TKey,TValue}.Clear"/>
596 public void PurgeExpired() 597 public void PurgeExpired()
597 { 598 {
598 lock( m_syncRoot ) 599 lock (m_syncRoot)
599 { 600 {
600 m_cache.PurgeExpired(); 601 m_cache.PurgeExpired();
601 } 602 }
@@ -615,11 +616,11 @@ namespace OpenSim.Framework
615 /// <seealso cref="ICnmCache{TKey,TValue}.TryGetValue"/> 616 /// <seealso cref="ICnmCache{TKey,TValue}.TryGetValue"/>
616 /// <seealso cref="ICnmCache{TKey,TValue}.Clear"/> 617 /// <seealso cref="ICnmCache{TKey,TValue}.Clear"/>
617 /// <seealso cref="ICnmCache{TKey,TValue}.PurgeExpired"/> 618 /// <seealso cref="ICnmCache{TKey,TValue}.PurgeExpired"/>
618 public void Remove( TKey key ) 619 public void Remove(TKey key)
619 { 620 {
620 lock( m_syncRoot ) 621 lock (m_syncRoot)
621 { 622 {
622 m_cache.Remove( key ); 623 m_cache.Remove(key);
623 } 624 }
624 } 625 }
625 626
@@ -637,11 +638,11 @@ namespace OpenSim.Framework
637 /// <seealso cref="ICnmCache{TKey,TValue}.TryGetValue"/> 638 /// <seealso cref="ICnmCache{TKey,TValue}.TryGetValue"/>
638 /// <seealso cref="ICnmCache{TKey,TValue}.Clear"/> 639 /// <seealso cref="ICnmCache{TKey,TValue}.Clear"/>
639 /// <seealso cref="ICnmCache{TKey,TValue}.PurgeExpired"/> 640 /// <seealso cref="ICnmCache{TKey,TValue}.PurgeExpired"/>
640 public void RemoveRange( IEnumerable<TKey> keys ) 641 public void RemoveRange(IEnumerable<TKey> keys)
641 { 642 {
642 lock( m_syncRoot ) 643 lock (m_syncRoot)
643 { 644 {
644 m_cache.RemoveRange( keys ); 645 m_cache.RemoveRange(keys);
645 } 646 }
646 } 647 }
647 648
@@ -690,11 +691,11 @@ namespace OpenSim.Framework
690 /// <seealso cref="ICnmCache{TKey,TValue}.TryGetValue"/> 691 /// <seealso cref="ICnmCache{TKey,TValue}.TryGetValue"/>
691 /// <seealso cref="ICnmCache{TKey,TValue}.Clear"/> 692 /// <seealso cref="ICnmCache{TKey,TValue}.Clear"/>
692 /// <seealso cref="ICnmCache{TKey,TValue}.PurgeExpired"/> 693 /// <seealso cref="ICnmCache{TKey,TValue}.PurgeExpired"/>
693 public bool Set( TKey key, TValue value, long size ) 694 public bool Set(TKey key, TValue value, long size)
694 { 695 {
695 lock( m_syncRoot ) 696 lock (m_syncRoot)
696 { 697 {
697 return m_cache.Set( key, value, size ); 698 return m_cache.Set(key, value, size);
698 } 699 }
699 } 700 }
700 701
@@ -721,11 +722,11 @@ namespace OpenSim.Framework
721 /// <seealso cref="ICnmCache{TKey,TValue}.RemoveRange"/> 722 /// <seealso cref="ICnmCache{TKey,TValue}.RemoveRange"/>
722 /// <seealso cref="ICnmCache{TKey,TValue}.Clear"/> 723 /// <seealso cref="ICnmCache{TKey,TValue}.Clear"/>
723 /// <seealso cref="ICnmCache{TKey,TValue}.PurgeExpired"/> 724 /// <seealso cref="ICnmCache{TKey,TValue}.PurgeExpired"/>
724 public bool TryGetValue( TKey key, out TValue value ) 725 public bool TryGetValue(TKey key, out TValue value)
725 { 726 {
726 lock( m_syncRoot ) 727 lock (m_syncRoot)
727 { 728 {
728 return m_cache.TryGetValue( key, out value ); 729 return m_cache.TryGetValue(key, out value);
729 } 730 }
730 } 731 }
731 732
diff --git a/OpenSim/Framework/PrimeNumberHelper.cs b/OpenSim/Framework/PrimeNumberHelper.cs
index 589f87d..477c274 100644
--- a/OpenSim/Framework/PrimeNumberHelper.cs
+++ b/OpenSim/Framework/PrimeNumberHelper.cs
@@ -58,28 +58,28 @@ namespace OpenSim.Framework
58 /// <returns> 58 /// <returns>
59 /// Primer number that is equal or larger than <see cref="min"/>. If <see cref="min"/> is too large, return -1. 59 /// Primer number that is equal or larger than <see cref="min"/>. If <see cref="min"/> is too large, return -1.
60 /// </returns> 60 /// </returns>
61 public static int GetPrime( int min ) 61 public static int GetPrime(int min)
62 { 62 {
63 if( min <= 2 ) 63 if (min <= 2)
64 return 2; 64 return 2;
65 65
66 if( Primes[ Primes.Length - 1 ] < min ) 66 if (Primes[ Primes.Length - 1 ] < min)
67 { 67 {
68 for( int i = min | 1 ; i < 0x7FFFFFFF ; i += 2 ) 68 for (int i = min | 1 ; i < 0x7FFFFFFF ; i += 2)
69 { 69 {
70 if( IsPrime( i ) ) 70 if (IsPrime(i))
71 return i; 71 return i;
72 } 72 }
73 73
74 return -1; 74 return -1;
75 } 75 }
76 76
77 for( int i = Primes.Length - 2 ; i >= 0 ; i-- ) 77 for (int i = Primes.Length - 2 ; i >= 0 ; i--)
78 { 78 {
79 if( min == Primes[ i ] ) 79 if (min == Primes[ i ])
80 return min; 80 return min;
81 81
82 if( min > Primes[ i ] ) 82 if (min > Primes[ i ])
83 return Primes[ i + 1 ]; 83 return Primes[ i + 1 ];
84 } 84 }
85 85
@@ -95,17 +95,17 @@ namespace OpenSim.Framework
95 /// <returns> 95 /// <returns>
96 /// true, if <see cref="candinate"/> is prime number; otherwise false. 96 /// true, if <see cref="candinate"/> is prime number; otherwise false.
97 /// </returns> 97 /// </returns>
98 public static bool IsPrime( int candinate ) 98 public static bool IsPrime(int candinate)
99 { 99 {
100 if( (candinate & 1) == 0 ) 100 if ((candinate & 1) == 0)
101 101
102 // Even number - only prime if 2 102 // Even number - only prime if 2
103 return candinate == 2; 103 return candinate == 2;
104 104
105 int upperBound = (int) Math.Sqrt( candinate ); 105 int upperBound = (int) Math.Sqrt(candinate);
106 for( int i = 3 ; i < upperBound ; i += 2 ) 106 for (int i = 3 ; i < upperBound ; i += 2)
107 { 107 {
108 if( candinate % i == 0 ) 108 if (candinate % i == 0)
109 return false; 109 return false;
110 } 110 }
111 111