aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/ThirdParty/SmartThreadPool/SynchronizedDictionary.cs
diff options
context:
space:
mode:
Diffstat (limited to 'ThirdParty/SmartThreadPool/SynchronizedDictionary.cs')
-rw-r--r--ThirdParty/SmartThreadPool/SynchronizedDictionary.cs178
1 files changed, 89 insertions, 89 deletions
diff --git a/ThirdParty/SmartThreadPool/SynchronizedDictionary.cs b/ThirdParty/SmartThreadPool/SynchronizedDictionary.cs
index 3532cca..0cce19f 100644
--- a/ThirdParty/SmartThreadPool/SynchronizedDictionary.cs
+++ b/ThirdParty/SmartThreadPool/SynchronizedDictionary.cs
@@ -1,89 +1,89 @@
1using System.Collections.Generic; 1using System.Collections.Generic;
2 2
3namespace Amib.Threading.Internal 3namespace Amib.Threading.Internal
4{ 4{
5 internal class SynchronizedDictionary<TKey, TValue> 5 internal class SynchronizedDictionary<TKey, TValue>
6 { 6 {
7 private readonly Dictionary<TKey, TValue> _dictionary; 7 private readonly Dictionary<TKey, TValue> _dictionary;
8 private readonly object _lock; 8 private readonly object _lock;
9 9
10 public SynchronizedDictionary() 10 public SynchronizedDictionary()
11 { 11 {
12 _lock = new object(); 12 _lock = new object();
13 _dictionary = new Dictionary<TKey, TValue>(); 13 _dictionary = new Dictionary<TKey, TValue>();
14 } 14 }
15 15
16 public int Count 16 public int Count
17 { 17 {
18 get { return _dictionary.Count; } 18 get { return _dictionary.Count; }
19 } 19 }
20 20
21 public bool Contains(TKey key) 21 public bool Contains(TKey key)
22 { 22 {
23 lock (_lock) 23 lock (_lock)
24 { 24 {
25 return _dictionary.ContainsKey(key); 25 return _dictionary.ContainsKey(key);
26 } 26 }
27 } 27 }
28 28
29 public void Remove(TKey key) 29 public void Remove(TKey key)
30 { 30 {
31 lock (_lock) 31 lock (_lock)
32 { 32 {
33 _dictionary.Remove(key); 33 _dictionary.Remove(key);
34 } 34 }
35 } 35 }
36 36
37 public object SyncRoot 37 public object SyncRoot
38 { 38 {
39 get { return _lock; } 39 get { return _lock; }
40 } 40 }
41 41
42 public TValue this[TKey key] 42 public TValue this[TKey key]
43 { 43 {
44 get 44 get
45 { 45 {
46 lock (_lock) 46 lock (_lock)
47 { 47 {
48 return _dictionary[key]; 48 return _dictionary[key];
49 } 49 }
50 } 50 }
51 set 51 set
52 { 52 {
53 lock (_lock) 53 lock (_lock)
54 { 54 {
55 _dictionary[key] = value; 55 _dictionary[key] = value;
56 } 56 }
57 } 57 }
58 } 58 }
59 59
60 public Dictionary<TKey, TValue>.KeyCollection Keys 60 public Dictionary<TKey, TValue>.KeyCollection Keys
61 { 61 {
62 get 62 get
63 { 63 {
64 lock (_lock) 64 lock (_lock)
65 { 65 {
66 return _dictionary.Keys; 66 return _dictionary.Keys;
67 } 67 }
68 } 68 }
69 } 69 }
70 70
71 public Dictionary<TKey, TValue>.ValueCollection Values 71 public Dictionary<TKey, TValue>.ValueCollection Values
72 { 72 {
73 get 73 get
74 { 74 {
75 lock (_lock) 75 lock (_lock)
76 { 76 {
77 return _dictionary.Values; 77 return _dictionary.Values;
78 } 78 }
79 } 79 }
80 } 80 }
81 public void Clear() 81 public void Clear()
82 { 82 {
83 lock (_lock) 83 lock (_lock)
84 { 84 {
85 _dictionary.Clear(); 85 _dictionary.Clear();
86 } 86 }
87 } 87 }
88 } 88 }
89} 89}