diff options
author | lbsa71 | 2007-10-30 09:05:31 +0000 |
---|---|---|
committer | lbsa71 | 2007-10-30 09:05:31 +0000 |
commit | 67e12b95ea7b68f4904a7484d77ecfd787d16d0c (patch) | |
tree | 20b00d24c8a7617017960432ec044852e3ad5fa9 /OpenSim/Framework/Communications/RestClient/GenericAsyncResult.cs | |
parent | * Deleted .user file (diff) | |
download | opensim-SC-67e12b95ea7b68f4904a7484d77ecfd787d16d0c.zip opensim-SC-67e12b95ea7b68f4904a7484d77ecfd787d16d0c.tar.gz opensim-SC-67e12b95ea7b68f4904a7484d77ecfd787d16d0c.tar.bz2 opensim-SC-67e12b95ea7b68f4904a7484d77ecfd787d16d0c.tar.xz |
* Optimized usings
* Shortened type references
* Removed redundant 'this' qualifier
Diffstat (limited to 'OpenSim/Framework/Communications/RestClient/GenericAsyncResult.cs')
-rw-r--r-- | OpenSim/Framework/Communications/RestClient/GenericAsyncResult.cs | 37 |
1 files changed, 16 insertions, 21 deletions
diff --git a/OpenSim/Framework/Communications/RestClient/GenericAsyncResult.cs b/OpenSim/Framework/Communications/RestClient/GenericAsyncResult.cs index c821fa4..72d8f65 100644 --- a/OpenSim/Framework/Communications/RestClient/GenericAsyncResult.cs +++ b/OpenSim/Framework/Communications/RestClient/GenericAsyncResult.cs | |||
@@ -1,13 +1,10 @@ | |||
1 | using System; | 1 | using System; |
2 | using System.Collections.Generic; | ||
3 | using System.Text; | ||
4 | using System.Threading; | 2 | using System.Threading; |
5 | 3 | ||
6 | namespace OpenSim.Framework.Communications | 4 | namespace OpenSim.Framework.Communications |
7 | { | 5 | { |
8 | internal class SimpleAsyncResult : IAsyncResult | 6 | internal class SimpleAsyncResult : IAsyncResult |
9 | { | 7 | { |
10 | |||
11 | private readonly AsyncCallback m_callback; | 8 | private readonly AsyncCallback m_callback; |
12 | 9 | ||
13 | /// <summary> | 10 | /// <summary> |
@@ -36,7 +33,6 @@ namespace OpenSim.Framework.Communications | |||
36 | m_completedSynchronously = 1; | 33 | m_completedSynchronously = 1; |
37 | } | 34 | } |
38 | 35 | ||
39 | |||
40 | #region IAsyncResult Members | 36 | #region IAsyncResult Members |
41 | 37 | ||
42 | public object AsyncState | 38 | public object AsyncState |
@@ -45,7 +41,6 @@ namespace OpenSim.Framework.Communications | |||
45 | } | 41 | } |
46 | 42 | ||
47 | 43 | ||
48 | |||
49 | public WaitHandle AsyncWaitHandle | 44 | public WaitHandle AsyncWaitHandle |
50 | { | 45 | { |
51 | get | 46 | get |
@@ -82,19 +77,18 @@ namespace OpenSim.Framework.Communications | |||
82 | get { return Thread.VolatileRead(ref m_completed) == 1; } | 77 | get { return Thread.VolatileRead(ref m_completed) == 1; } |
83 | } | 78 | } |
84 | 79 | ||
85 | |||
86 | #endregion | 80 | #endregion |
87 | 81 | ||
88 | |||
89 | #region class Methods | 82 | #region class Methods |
83 | |||
90 | internal void SetAsCompleted(bool completedSynchronously) | 84 | internal void SetAsCompleted(bool completedSynchronously) |
91 | { | 85 | { |
92 | m_completed = 1; | 86 | m_completed = 1; |
93 | if(completedSynchronously) | 87 | if (completedSynchronously) |
94 | m_completedSynchronously = 1; | 88 | m_completedSynchronously = 1; |
95 | else | 89 | else |
96 | m_completedSynchronously = 0; | 90 | m_completedSynchronously = 0; |
97 | 91 | ||
98 | SignalCompletion(); | 92 | SignalCompletion(); |
99 | } | 93 | } |
100 | 94 | ||
@@ -112,9 +106,9 @@ namespace OpenSim.Framework.Communications | |||
112 | 106 | ||
113 | private void SignalCompletion() | 107 | private void SignalCompletion() |
114 | { | 108 | { |
115 | if(m_waitHandle != null) m_waitHandle.Set(); | 109 | if (m_waitHandle != null) m_waitHandle.Set(); |
116 | 110 | ||
117 | if(m_callback != null) m_callback(this); | 111 | if (m_callback != null) m_callback(this); |
118 | } | 112 | } |
119 | 113 | ||
120 | public void EndInvoke() | 114 | public void EndInvoke() |
@@ -125,14 +119,14 @@ namespace OpenSim.Framework.Communications | |||
125 | // If the operation isn't done, wait for it | 119 | // If the operation isn't done, wait for it |
126 | AsyncWaitHandle.WaitOne(); | 120 | AsyncWaitHandle.WaitOne(); |
127 | AsyncWaitHandle.Close(); | 121 | AsyncWaitHandle.Close(); |
128 | m_waitHandle = null; // Allow early GC | 122 | m_waitHandle = null; // Allow early GC |
129 | } | 123 | } |
130 | 124 | ||
131 | // Operation is done: if an exception occured, throw it | 125 | // Operation is done: if an exception occured, throw it |
132 | if (m_exception != null) throw m_exception; | 126 | if (m_exception != null) throw m_exception; |
133 | } | 127 | } |
134 | 128 | ||
135 | #endregion | 129 | #endregion |
136 | } | 130 | } |
137 | 131 | ||
138 | internal class AsyncResult<T> : SimpleAsyncResult | 132 | internal class AsyncResult<T> : SimpleAsyncResult |
@@ -140,10 +134,12 @@ namespace OpenSim.Framework.Communications | |||
140 | private T m_result = default(T); | 134 | private T m_result = default(T); |
141 | 135 | ||
142 | public AsyncResult(AsyncCallback asyncCallback, Object state) : | 136 | public AsyncResult(AsyncCallback asyncCallback, Object state) : |
143 | base(asyncCallback, state) { } | 137 | base(asyncCallback, state) |
138 | { | ||
139 | } | ||
144 | 140 | ||
145 | 141 | ||
146 | public void SetAsCompleted(T result, bool completedSynchronously) | 142 | public void SetAsCompleted(T result, bool completedSynchronously) |
147 | { | 143 | { |
148 | // Save the asynchronous operation's result | 144 | // Save the asynchronous operation's result |
149 | m_result = result; | 145 | m_result = result; |
@@ -153,11 +149,10 @@ namespace OpenSim.Framework.Communications | |||
153 | base.SetAsCompleted(completedSynchronously); | 149 | base.SetAsCompleted(completedSynchronously); |
154 | } | 150 | } |
155 | 151 | ||
156 | new public T EndInvoke() | 152 | public new T EndInvoke() |
157 | { | 153 | { |
158 | base.EndInvoke(); | 154 | base.EndInvoke(); |
159 | return m_result; | 155 | return m_result; |
160 | } | 156 | } |
161 | |||
162 | } | 157 | } |
163 | } | 158 | } \ No newline at end of file |