diff options
author | David Walter Seikel | 2016-11-03 21:44:39 +1000 |
---|---|---|
committer | David Walter Seikel | 2016-11-03 21:44:39 +1000 |
commit | 134f86e8d5c414409631b25b8c6f0ee45fbd8631 (patch) | |
tree | 216b89d3fb89acfb81be1e440c25c41ab09fa96d /ThirdParty/SmartThreadPool/SynchronizedDictionary.cs | |
parent | More changing to production grid. Double oops. (diff) | |
download | opensim-SC-134f86e8d5c414409631b25b8c6f0ee45fbd8631.zip opensim-SC-134f86e8d5c414409631b25b8c6f0ee45fbd8631.tar.gz opensim-SC-134f86e8d5c414409631b25b8c6f0ee45fbd8631.tar.bz2 opensim-SC-134f86e8d5c414409631b25b8c6f0ee45fbd8631.tar.xz |
Initial update to OpenSim 0.8.2.1 source code.
Diffstat (limited to '')
-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 | } | ||