diff options
author | Justin Clark-Casey (justincc) | 2013-05-01 23:00:46 +0100 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2013-05-01 23:00:46 +0100 |
commit | 854dcd1abddc3eef33da953592deb61133e5e7ed (patch) | |
tree | d89d9d616384fdb4e6b4eec658339eac2f079ff2 /ThirdParty/SmartThreadPool/EventWaitHandleFactory.cs | |
parent | Add in-code exaplanation for the change in cancellation signalling in STP 2.2... (diff) | |
download | opensim-SC-854dcd1abddc3eef33da953592deb61133e5e7ed.zip opensim-SC-854dcd1abddc3eef33da953592deb61133e5e7ed.tar.gz opensim-SC-854dcd1abddc3eef33da953592deb61133e5e7ed.tar.bz2 opensim-SC-854dcd1abddc3eef33da953592deb61133e5e7ed.tar.xz |
Fix SmartThreadPool line endings in recent update from dos to unix
Diffstat (limited to '')
-rw-r--r-- | ThirdParty/SmartThreadPool/EventWaitHandleFactory.cs | 164 |
1 files changed, 82 insertions, 82 deletions
diff --git a/ThirdParty/SmartThreadPool/EventWaitHandleFactory.cs b/ThirdParty/SmartThreadPool/EventWaitHandleFactory.cs index 2f8c55b..3c9c849 100644 --- a/ThirdParty/SmartThreadPool/EventWaitHandleFactory.cs +++ b/ThirdParty/SmartThreadPool/EventWaitHandleFactory.cs | |||
@@ -1,82 +1,82 @@ | |||
1 | using System.Threading; | 1 | using System.Threading; |
2 | 2 | ||
3 | #if (_WINDOWS_CE) | 3 | #if (_WINDOWS_CE) |
4 | using System; | 4 | using System; |
5 | using System.Runtime.InteropServices; | 5 | using System.Runtime.InteropServices; |
6 | #endif | 6 | #endif |
7 | 7 | ||
8 | namespace Amib.Threading.Internal | 8 | namespace Amib.Threading.Internal |
9 | { | 9 | { |
10 | /// <summary> | 10 | /// <summary> |
11 | /// EventWaitHandleFactory class. | 11 | /// EventWaitHandleFactory class. |
12 | /// This is a static class that creates AutoResetEvent and ManualResetEvent objects. | 12 | /// This is a static class that creates AutoResetEvent and ManualResetEvent objects. |
13 | /// In WindowCE the WaitForMultipleObjects API fails to use the Handle property | 13 | /// In WindowCE the WaitForMultipleObjects API fails to use the Handle property |
14 | /// of XxxResetEvent. It can use only handles that were created by the CreateEvent API. | 14 | /// of XxxResetEvent. It can use only handles that were created by the CreateEvent API. |
15 | /// Consequently this class creates the needed XxxResetEvent and replaces the handle if | 15 | /// Consequently this class creates the needed XxxResetEvent and replaces the handle if |
16 | /// it's a WindowsCE OS. | 16 | /// it's a WindowsCE OS. |
17 | /// </summary> | 17 | /// </summary> |
18 | public static class EventWaitHandleFactory | 18 | public static class EventWaitHandleFactory |
19 | { | 19 | { |
20 | /// <summary> | 20 | /// <summary> |
21 | /// Create a new AutoResetEvent object | 21 | /// Create a new AutoResetEvent object |
22 | /// </summary> | 22 | /// </summary> |
23 | /// <returns>Return a new AutoResetEvent object</returns> | 23 | /// <returns>Return a new AutoResetEvent object</returns> |
24 | public static AutoResetEvent CreateAutoResetEvent() | 24 | public static AutoResetEvent CreateAutoResetEvent() |
25 | { | 25 | { |
26 | AutoResetEvent waitHandle = new AutoResetEvent(false); | 26 | AutoResetEvent waitHandle = new AutoResetEvent(false); |
27 | 27 | ||
28 | #if (_WINDOWS_CE) | 28 | #if (_WINDOWS_CE) |
29 | ReplaceEventHandle(waitHandle, false, false); | 29 | ReplaceEventHandle(waitHandle, false, false); |
30 | #endif | 30 | #endif |
31 | 31 | ||
32 | return waitHandle; | 32 | return waitHandle; |
33 | } | 33 | } |
34 | 34 | ||
35 | /// <summary> | 35 | /// <summary> |
36 | /// Create a new ManualResetEvent object | 36 | /// Create a new ManualResetEvent object |
37 | /// </summary> | 37 | /// </summary> |
38 | /// <returns>Return a new ManualResetEvent object</returns> | 38 | /// <returns>Return a new ManualResetEvent object</returns> |
39 | public static ManualResetEvent CreateManualResetEvent(bool initialState) | 39 | public static ManualResetEvent CreateManualResetEvent(bool initialState) |
40 | { | 40 | { |
41 | ManualResetEvent waitHandle = new ManualResetEvent(initialState); | 41 | ManualResetEvent waitHandle = new ManualResetEvent(initialState); |
42 | 42 | ||
43 | #if (_WINDOWS_CE) | 43 | #if (_WINDOWS_CE) |
44 | ReplaceEventHandle(waitHandle, true, initialState); | 44 | ReplaceEventHandle(waitHandle, true, initialState); |
45 | #endif | 45 | #endif |
46 | 46 | ||
47 | return waitHandle; | 47 | return waitHandle; |
48 | } | 48 | } |
49 | 49 | ||
50 | #if (_WINDOWS_CE) | 50 | #if (_WINDOWS_CE) |
51 | 51 | ||
52 | /// <summary> | 52 | /// <summary> |
53 | /// Replace the event handle | 53 | /// Replace the event handle |
54 | /// </summary> | 54 | /// </summary> |
55 | /// <param name="waitHandle">The WaitHandle object which its handle needs to be replaced.</param> | 55 | /// <param name="waitHandle">The WaitHandle object which its handle needs to be replaced.</param> |
56 | /// <param name="manualReset">Indicates if the event is a ManualResetEvent (true) or an AutoResetEvent (false)</param> | 56 | /// <param name="manualReset">Indicates if the event is a ManualResetEvent (true) or an AutoResetEvent (false)</param> |
57 | /// <param name="initialState">The initial state of the event</param> | 57 | /// <param name="initialState">The initial state of the event</param> |
58 | private static void ReplaceEventHandle(WaitHandle waitHandle, bool manualReset, bool initialState) | 58 | private static void ReplaceEventHandle(WaitHandle waitHandle, bool manualReset, bool initialState) |
59 | { | 59 | { |
60 | // Store the old handle | 60 | // Store the old handle |
61 | IntPtr oldHandle = waitHandle.Handle; | 61 | IntPtr oldHandle = waitHandle.Handle; |
62 | 62 | ||
63 | // Create a new event | 63 | // Create a new event |
64 | IntPtr newHandle = CreateEvent(IntPtr.Zero, manualReset, initialState, null); | 64 | IntPtr newHandle = CreateEvent(IntPtr.Zero, manualReset, initialState, null); |
65 | 65 | ||
66 | // Replace the old event with the new event | 66 | // Replace the old event with the new event |
67 | waitHandle.Handle = newHandle; | 67 | waitHandle.Handle = newHandle; |
68 | 68 | ||
69 | // Close the old event | 69 | // Close the old event |
70 | CloseHandle (oldHandle); | 70 | CloseHandle (oldHandle); |
71 | } | 71 | } |
72 | 72 | ||
73 | [DllImport("coredll.dll", SetLastError = true)] | 73 | [DllImport("coredll.dll", SetLastError = true)] |
74 | public static extern IntPtr CreateEvent(IntPtr lpEventAttributes, bool bManualReset, bool bInitialState, string lpName); | 74 | public static extern IntPtr CreateEvent(IntPtr lpEventAttributes, bool bManualReset, bool bInitialState, string lpName); |
75 | 75 | ||
76 | //Handle | 76 | //Handle |
77 | [DllImport("coredll.dll", SetLastError = true)] | 77 | [DllImport("coredll.dll", SetLastError = true)] |
78 | public static extern bool CloseHandle(IntPtr hObject); | 78 | public static extern bool CloseHandle(IntPtr hObject); |
79 | #endif | 79 | #endif |
80 | 80 | ||
81 | } | 81 | } |
82 | } | 82 | } |