aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/ThirdParty/SmartThreadPool/Interfaces.cs
diff options
context:
space:
mode:
authorTeravus Ovares2008-05-30 12:27:06 +0000
committerTeravus Ovares2008-05-30 12:27:06 +0000
commit1a47ff8094ee414a47aebd310826906d89428a09 (patch)
tree0e90b3a33f43ff8617a077bb57b86d6b28e63e71 /ThirdParty/SmartThreadPool/Interfaces.cs
parent* Fixed a dangling event hook that I added. (diff)
downloadopensim-SC_OLD-1a47ff8094ee414a47aebd310826906d89428a09.zip
opensim-SC_OLD-1a47ff8094ee414a47aebd310826906d89428a09.tar.gz
opensim-SC_OLD-1a47ff8094ee414a47aebd310826906d89428a09.tar.bz2
opensim-SC_OLD-1a47ff8094ee414a47aebd310826906d89428a09.tar.xz
* This is Melanie's XEngine script engine. I've not tested this real well, however, it's confirmed to compile and OpenSimulator to run successfully without this script engine active.
Diffstat (limited to 'ThirdParty/SmartThreadPool/Interfaces.cs')
-rw-r--r--ThirdParty/SmartThreadPool/Interfaces.cs271
1 files changed, 271 insertions, 0 deletions
diff --git a/ThirdParty/SmartThreadPool/Interfaces.cs b/ThirdParty/SmartThreadPool/Interfaces.cs
new file mode 100644
index 0000000..f1c1fcf
--- /dev/null
+++ b/ThirdParty/SmartThreadPool/Interfaces.cs
@@ -0,0 +1,271 @@
1// Ami Bar
2// amibar@gmail.com
3
4using System;
5using System.Threading;
6
7namespace Amib.Threading
8{
9 #region Delegates
10
11 /// <summary>
12 /// A delegate that represents the method to run as the work item
13 /// </summary>
14 /// <param name="state">A state object for the method to run</param>
15 public delegate object WorkItemCallback(object state);
16
17 /// <summary>
18 /// A delegate to call after the WorkItemCallback completed
19 /// </summary>
20 /// <param name="wir">The work item result object</param>
21 public delegate void PostExecuteWorkItemCallback(IWorkItemResult wir);
22
23 /// <summary>
24 /// A delegate to call when a WorkItemsGroup becomes idle
25 /// </summary>
26 /// <param name="workItemsGroup">A reference to the WorkItemsGroup that became idle</param>
27 public delegate void WorkItemsGroupIdleHandler(IWorkItemsGroup workItemsGroup);
28
29 #endregion
30
31 #region WorkItem Priority
32
33 public enum WorkItemPriority
34 {
35 Lowest,
36 BelowNormal,
37 Normal,
38 AboveNormal,
39 Highest,
40 }
41
42 #endregion
43
44 #region IHasWorkItemPriority interface
45
46 public interface IHasWorkItemPriority
47 {
48 WorkItemPriority WorkItemPriority { get; }
49 }
50
51 #endregion
52
53 #region IWorkItemsGroup interface
54
55 /// <summary>
56 /// IWorkItemsGroup interface
57 /// </summary>
58 public interface IWorkItemsGroup
59 {
60 /// <summary>
61 /// Get/Set the name of the WorkItemsGroup
62 /// </summary>
63 string Name { get; set; }
64
65 IWorkItemResult QueueWorkItem(WorkItemCallback callback);
66 IWorkItemResult QueueWorkItem(WorkItemCallback callback, WorkItemPriority workItemPriority);
67 IWorkItemResult QueueWorkItem(WorkItemCallback callback, object state);
68 IWorkItemResult QueueWorkItem(WorkItemCallback callback, object state, WorkItemPriority workItemPriority);
69 IWorkItemResult QueueWorkItem(WorkItemCallback callback, object state, PostExecuteWorkItemCallback postExecuteWorkItemCallback);
70 IWorkItemResult QueueWorkItem(WorkItemCallback callback, object state, PostExecuteWorkItemCallback postExecuteWorkItemCallback, WorkItemPriority workItemPriority);
71 IWorkItemResult QueueWorkItem(WorkItemCallback callback, object state, PostExecuteWorkItemCallback postExecuteWorkItemCallback, CallToPostExecute callToPostExecute);
72 IWorkItemResult QueueWorkItem(WorkItemCallback callback, object state, PostExecuteWorkItemCallback postExecuteWorkItemCallback, CallToPostExecute callToPostExecute, WorkItemPriority workItemPriority);
73
74 IWorkItemResult QueueWorkItem(WorkItemInfo workItemInfo, WorkItemCallback callback);
75 IWorkItemResult QueueWorkItem(WorkItemInfo workItemInfo, WorkItemCallback callback, object state);
76
77 void WaitForIdle();
78 bool WaitForIdle(TimeSpan timeout);
79 bool WaitForIdle(int millisecondsTimeout);
80
81 int WaitingCallbacks { get; }
82 event WorkItemsGroupIdleHandler OnIdle;
83
84 void Cancel();
85 void Start();
86 }
87
88 #endregion
89
90 #region CallToPostExecute enumerator
91
92 [Flags]
93 public enum CallToPostExecute
94 {
95 Never = 0x00,
96 WhenWorkItemCanceled = 0x01,
97 WhenWorkItemNotCanceled = 0x02,
98 Always = WhenWorkItemCanceled | WhenWorkItemNotCanceled,
99 }
100
101 #endregion
102
103 #region IWorkItemResult interface
104
105 /// <summary>
106 /// IWorkItemResult interface
107 /// </summary>
108 public interface IWorkItemResult
109 {
110 /// <summary>
111 /// Get the result of the work item.
112 /// If the work item didn't run yet then the caller waits.
113 /// </summary>
114 /// <returns>The result of the work item</returns>
115 object GetResult();
116
117 /// <summary>
118 /// Get the result of the work item.
119 /// If the work item didn't run yet then the caller waits until timeout.
120 /// </summary>
121 /// <returns>The result of the work item</returns>
122 /// On timeout throws WorkItemTimeoutException
123 object GetResult(
124 int millisecondsTimeout,
125 bool exitContext);
126
127 /// <summary>
128 /// Get the result of the work item.
129 /// If the work item didn't run yet then the caller waits until timeout.
130 /// </summary>
131 /// <returns>The result of the work item</returns>
132 /// On timeout throws WorkItemTimeoutException
133 object GetResult(
134 TimeSpan timeout,
135 bool exitContext);
136
137 void Abort();
138
139 /// <summary>
140 /// Get the result of the work item.
141 /// If the work item didn't run yet then the caller waits until timeout or until the cancelWaitHandle is signaled.
142 /// </summary>
143 /// <param name="millisecondsTimeout">Timeout in milliseconds, or -1 for infinite</param>
144 /// <param name="exitContext">
145 /// true to exit the synchronization domain for the context before the wait (if in a synchronized context), and reacquire it; otherwise, false.
146 /// </param>
147 /// <param name="cancelWaitHandle">A cancel wait handle to interrupt the blocking if needed</param>
148 /// <returns>The result of the work item</returns>
149 /// On timeout throws WorkItemTimeoutException
150 /// On cancel throws WorkItemCancelException
151 object GetResult(
152 int millisecondsTimeout,
153 bool exitContext,
154 WaitHandle cancelWaitHandle);
155
156 /// <summary>
157 /// Get the result of the work item.
158 /// If the work item didn't run yet then the caller waits until timeout or until the cancelWaitHandle is signaled.
159 /// </summary>
160 /// <returns>The result of the work item</returns>
161 /// On timeout throws WorkItemTimeoutException
162 /// On cancel throws WorkItemCancelException
163 object GetResult(
164 TimeSpan timeout,
165 bool exitContext,
166 WaitHandle cancelWaitHandle);
167
168 /// <summary>
169 /// Get the result of the work item.
170 /// If the work item didn't run yet then the caller waits.
171 /// </summary>
172 /// <param name="e">Filled with the exception if one was thrown</param>
173 /// <returns>The result of the work item</returns>
174 object GetResult(out Exception e);
175
176 /// <summary>
177 /// Get the result of the work item.
178 /// If the work item didn't run yet then the caller waits until timeout.
179 /// </summary>
180 /// <param name="e">Filled with the exception if one was thrown</param>
181 /// <returns>The result of the work item</returns>
182 /// On timeout throws WorkItemTimeoutException
183 object GetResult(
184 int millisecondsTimeout,
185 bool exitContext,
186 out Exception e);
187
188 /// <summary>
189 /// Get the result of the work item.
190 /// If the work item didn't run yet then the caller waits until timeout.
191 /// </summary>
192 /// <param name="e">Filled with the exception if one was thrown</param>
193 /// <returns>The result of the work item</returns>
194 /// On timeout throws WorkItemTimeoutException
195 object GetResult(
196 TimeSpan timeout,
197 bool exitContext,
198 out Exception e);
199
200 /// <summary>
201 /// Get the result of the work item.
202 /// If the work item didn't run yet then the caller waits until timeout or until the cancelWaitHandle is signaled.
203 /// </summary>
204 /// <param name="millisecondsTimeout">Timeout in milliseconds, or -1 for infinite</param>
205 /// <param name="exitContext">
206 /// true to exit the synchronization domain for the context before the wait (if in a synchronized context), and reacquire it; otherwise, false.
207 /// </param>
208 /// <param name="cancelWaitHandle">A cancel wait handle to interrupt the blocking if needed</param>
209 /// <param name="e">Filled with the exception if one was thrown</param>
210 /// <returns>The result of the work item</returns>
211 /// On timeout throws WorkItemTimeoutException
212 /// On cancel throws WorkItemCancelException
213 object GetResult(
214 int millisecondsTimeout,
215 bool exitContext,
216 WaitHandle cancelWaitHandle,
217 out Exception e);
218
219 /// <summary>
220 /// Get the result of the work item.
221 /// If the work item didn't run yet then the caller waits until timeout or until the cancelWaitHandle is signaled.
222 /// </summary>
223 /// <returns>The result of the work item</returns>
224 /// <param name="e">Filled with the exception if one was thrown</param>
225 /// On timeout throws WorkItemTimeoutException
226 /// On cancel throws WorkItemCancelException
227 object GetResult(
228 TimeSpan timeout,
229 bool exitContext,
230 WaitHandle cancelWaitHandle,
231 out Exception e);
232
233 /// <summary>
234 /// Gets an indication whether the asynchronous operation has completed.
235 /// </summary>
236 bool IsCompleted { get; }
237
238 /// <summary>
239 /// Gets an indication whether the asynchronous operation has been canceled.
240 /// </summary>
241 bool IsCanceled { get; }
242
243 /// <summary>
244 /// Gets a user-defined object that qualifies or contains information about an asynchronous operation.
245 /// </summary>
246 object State { get; }
247
248 /// <summary>
249 /// Cancel the work item if it didn't start running yet.
250 /// </summary>
251 /// <returns>Returns true on success or false if the work item is in progress or already completed</returns>
252 bool Cancel();
253
254 /// <summary>
255 /// Get the work item's priority
256 /// </summary>
257 WorkItemPriority WorkItemPriority { get; }
258
259 /// <summary>
260 /// Return the result, same as GetResult()
261 /// </summary>
262 object Result { get; }
263
264 /// <summary>
265 /// Returns the exception if occured otherwise returns null.
266 /// </summary>
267 object Exception { get; }
268 }
269
270 #endregion
271}