diff options
author | Melanie Thielker | 2014-06-21 00:39:55 +0200 |
---|---|---|
committer | Melanie Thielker | 2014-06-21 00:39:55 +0200 |
commit | 159fcbf150b7da0e229b29aa7b94793484543d12 (patch) | |
tree | b8c0ff3b4c758a3fba8315b556c923ef4c02a185 /ThirdParty/SmartThreadPool/SynchronizedDictionary.cs | |
parent | Merge commit '68c8633ba18f0a11cfc0ed04d1d0c7c59e6cec76' (diff) | |
parent | Merge branch 'master' into careminster (diff) | |
download | opensim-SC_OLD-159fcbf150b7da0e229b29aa7b94793484543d12.zip opensim-SC_OLD-159fcbf150b7da0e229b29aa7b94793484543d12.tar.gz opensim-SC_OLD-159fcbf150b7da0e229b29aa7b94793484543d12.tar.bz2 opensim-SC_OLD-159fcbf150b7da0e229b29aa7b94793484543d12.tar.xz |
Merge branch 'master' of ssh://3dhosting.de/var/git/careminster
Conflicts:
OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
Diffstat (limited to 'ThirdParty/SmartThreadPool/SynchronizedDictionary.cs')
-rw-r--r-- | ThirdParty/SmartThreadPool/SynchronizedDictionary.cs | 89 |
1 files changed, 89 insertions, 0 deletions
diff --git a/ThirdParty/SmartThreadPool/SynchronizedDictionary.cs b/ThirdParty/SmartThreadPool/SynchronizedDictionary.cs new file mode 100644 index 0000000..0cce19f --- /dev/null +++ b/ThirdParty/SmartThreadPool/SynchronizedDictionary.cs | |||
@@ -0,0 +1,89 @@ | |||
1 | using System.Collections.Generic; | ||
2 | |||
3 | namespace Amib.Threading.Internal | ||
4 | { | ||
5 | internal class SynchronizedDictionary<TKey, TValue> | ||
6 | { | ||
7 | private readonly Dictionary<TKey, TValue> _dictionary; | ||
8 | private readonly object _lock; | ||
9 | |||
10 | public SynchronizedDictionary() | ||
11 | { | ||
12 | _lock = new object(); | ||
13 | _dictionary = new Dictionary<TKey, TValue>(); | ||
14 | } | ||
15 | |||
16 | public int Count | ||
17 | { | ||
18 | get { return _dictionary.Count; } | ||
19 | } | ||
20 | |||
21 | public bool Contains(TKey key) | ||
22 | { | ||
23 | lock (_lock) | ||
24 | { | ||
25 | return _dictionary.ContainsKey(key); | ||
26 | } | ||
27 | } | ||
28 | |||
29 | public void Remove(TKey key) | ||
30 | { | ||
31 | lock (_lock) | ||
32 | { | ||
33 | _dictionary.Remove(key); | ||
34 | } | ||
35 | } | ||
36 | |||
37 | public object SyncRoot | ||
38 | { | ||
39 | get { return _lock; } | ||
40 | } | ||
41 | |||
42 | public TValue this[TKey key] | ||
43 | { | ||
44 | get | ||
45 | { | ||
46 | lock (_lock) | ||
47 | { | ||
48 | return _dictionary[key]; | ||
49 | } | ||
50 | } | ||
51 | set | ||
52 | { | ||
53 | lock (_lock) | ||
54 | { | ||
55 | _dictionary[key] = value; | ||
56 | } | ||
57 | } | ||
58 | } | ||
59 | |||
60 | public Dictionary<TKey, TValue>.KeyCollection Keys | ||
61 | { | ||
62 | get | ||
63 | { | ||
64 | lock (_lock) | ||
65 | { | ||
66 | return _dictionary.Keys; | ||
67 | } | ||
68 | } | ||
69 | } | ||
70 | |||
71 | public Dictionary<TKey, TValue>.ValueCollection Values | ||
72 | { | ||
73 | get | ||
74 | { | ||
75 | lock (_lock) | ||
76 | { | ||
77 | return _dictionary.Values; | ||
78 | } | ||
79 | } | ||
80 | } | ||
81 | public void Clear() | ||
82 | { | ||
83 | lock (_lock) | ||
84 | { | ||
85 | _dictionary.Clear(); | ||
86 | } | ||
87 | } | ||
88 | } | ||
89 | } | ||