aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/CnmSynchronizedCache.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Framework/CnmSynchronizedCache.cs')
-rw-r--r--OpenSim/Framework/CnmSynchronizedCache.cs77
1 files changed, 39 insertions, 38 deletions
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