From 854dcd1abddc3eef33da953592deb61133e5e7ed Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Wed, 1 May 2013 23:00:46 +0100
Subject: Fix SmartThreadPool line endings in recent update from dos to unix
---
ThirdParty/SmartThreadPool/CallerThreadContext.cs | 276 +-
.../SmartThreadPool/CanceledWorkItemsGroup.cs | 26 +-
ThirdParty/SmartThreadPool/EventWaitHandle.cs | 206 +-
.../SmartThreadPool/EventWaitHandleFactory.cs | 164 +-
ThirdParty/SmartThreadPool/Exceptions.cs | 222 +-
ThirdParty/SmartThreadPool/Interfaces.cs | 1256 +++----
ThirdParty/SmartThreadPool/InternalInterfaces.cs | 54 +-
ThirdParty/SmartThreadPool/PriorityQueue.cs | 478 +--
.../SmartThreadPool/Properties/AssemblyInfo.cs | 46 +-
ThirdParty/SmartThreadPool/SLExt.cs | 32 +-
ThirdParty/SmartThreadPool/STPEventWaitHandle.cs | 122 +-
.../SmartThreadPool/STPPerformanceCounter.cs | 896 ++---
ThirdParty/SmartThreadPool/STPStartInfo.cs | 424 +--
.../SmartThreadPool/SmartThreadPool.ThreadEntry.cs | 118 +-
ThirdParty/SmartThreadPool/SmartThreadPool.cs | 3464 ++++++++++----------
.../SmartThreadPool/SynchronizedDictionary.cs | 178 +-
ThirdParty/SmartThreadPool/WIGStartInfo.cs | 342 +-
.../SmartThreadPool/WorkItem.WorkItemResult.cs | 380 +--
ThirdParty/SmartThreadPool/WorkItemFactory.cs | 686 ++--
ThirdParty/SmartThreadPool/WorkItemInfo.cs | 138 +-
.../SmartThreadPool/WorkItemResultTWrapper.cs | 256 +-
ThirdParty/SmartThreadPool/WorkItemsGroup.cs | 722 ++--
ThirdParty/SmartThreadPool/WorkItemsGroupBase.cs | 940 +++---
ThirdParty/SmartThreadPool/WorkItemsQueue.cs | 1290 ++++----
24 files changed, 6358 insertions(+), 6358 deletions(-)
(limited to 'ThirdParty/SmartThreadPool')
diff --git a/ThirdParty/SmartThreadPool/CallerThreadContext.cs b/ThirdParty/SmartThreadPool/CallerThreadContext.cs
index 2177241..e63add5 100644
--- a/ThirdParty/SmartThreadPool/CallerThreadContext.cs
+++ b/ThirdParty/SmartThreadPool/CallerThreadContext.cs
@@ -1,138 +1,138 @@
-
-#if !(_WINDOWS_CE) && !(_SILVERLIGHT) && !(WINDOWS_PHONE)
-
-using System;
-using System.Diagnostics;
-using System.Threading;
-using System.Reflection;
-using System.Web;
-using System.Runtime.Remoting.Messaging;
-
-
-namespace Amib.Threading.Internal
-{
-#region CallerThreadContext class
-
- ///
- /// This class stores the caller call context in order to restore
- /// it when the work item is executed in the thread pool environment.
- ///
- internal class CallerThreadContext
- {
-#region Prepare reflection information
-
- // Cached type information.
- private static readonly MethodInfo getLogicalCallContextMethodInfo =
- typeof(Thread).GetMethod("GetLogicalCallContext", BindingFlags.Instance | BindingFlags.NonPublic);
-
- private static readonly MethodInfo setLogicalCallContextMethodInfo =
- typeof(Thread).GetMethod("SetLogicalCallContext", BindingFlags.Instance | BindingFlags.NonPublic);
-
- private static string HttpContextSlotName = GetHttpContextSlotName();
-
- private static string GetHttpContextSlotName()
- {
- FieldInfo fi = typeof(HttpContext).GetField("CallContextSlotName", BindingFlags.Static | BindingFlags.NonPublic);
-
- if (fi != null)
- {
- return (string) fi.GetValue(null);
- }
-
- return "HttpContext";
- }
-
- #endregion
-
-#region Private fields
-
- private HttpContext _httpContext;
- private LogicalCallContext _callContext;
-
- #endregion
-
- ///
- /// Constructor
- ///
- private CallerThreadContext()
- {
- }
-
- public bool CapturedCallContext
- {
- get
- {
- return (null != _callContext);
- }
- }
-
- public bool CapturedHttpContext
- {
- get
- {
- return (null != _httpContext);
- }
- }
-
- ///
- /// Captures the current thread context
- ///
- ///
- public static CallerThreadContext Capture(
- bool captureCallContext,
- bool captureHttpContext)
- {
- Debug.Assert(captureCallContext || captureHttpContext);
-
- CallerThreadContext callerThreadContext = new CallerThreadContext();
-
- // TODO: In NET 2.0, redo using the new feature of ExecutionContext class - Capture()
- // Capture Call Context
- if(captureCallContext && (getLogicalCallContextMethodInfo != null))
- {
- callerThreadContext._callContext = (LogicalCallContext)getLogicalCallContextMethodInfo.Invoke(Thread.CurrentThread, null);
- if (callerThreadContext._callContext != null)
- {
- callerThreadContext._callContext = (LogicalCallContext)callerThreadContext._callContext.Clone();
- }
- }
-
- // Capture httpContext
- if (captureHttpContext && (null != HttpContext.Current))
- {
- callerThreadContext._httpContext = HttpContext.Current;
- }
-
- return callerThreadContext;
- }
-
- ///
- /// Applies the thread context stored earlier
- ///
- ///
- public static void Apply(CallerThreadContext callerThreadContext)
- {
- if (null == callerThreadContext)
- {
- throw new ArgumentNullException("callerThreadContext");
- }
-
- // Todo: In NET 2.0, redo using the new feature of ExecutionContext class - Run()
- // Restore call context
- if ((callerThreadContext._callContext != null) && (setLogicalCallContextMethodInfo != null))
- {
- setLogicalCallContextMethodInfo.Invoke(Thread.CurrentThread, new object[] { callerThreadContext._callContext });
- }
-
- // Restore HttpContext
- if (callerThreadContext._httpContext != null)
- {
- HttpContext.Current = callerThreadContext._httpContext;
- //CallContext.SetData(HttpContextSlotName, callerThreadContext._httpContext);
- }
- }
- }
-
- #endregion
-}
-#endif
+
+#if !(_WINDOWS_CE) && !(_SILVERLIGHT) && !(WINDOWS_PHONE)
+
+using System;
+using System.Diagnostics;
+using System.Threading;
+using System.Reflection;
+using System.Web;
+using System.Runtime.Remoting.Messaging;
+
+
+namespace Amib.Threading.Internal
+{
+#region CallerThreadContext class
+
+ ///
+ /// This class stores the caller call context in order to restore
+ /// it when the work item is executed in the thread pool environment.
+ ///
+ internal class CallerThreadContext
+ {
+#region Prepare reflection information
+
+ // Cached type information.
+ private static readonly MethodInfo getLogicalCallContextMethodInfo =
+ typeof(Thread).GetMethod("GetLogicalCallContext", BindingFlags.Instance | BindingFlags.NonPublic);
+
+ private static readonly MethodInfo setLogicalCallContextMethodInfo =
+ typeof(Thread).GetMethod("SetLogicalCallContext", BindingFlags.Instance | BindingFlags.NonPublic);
+
+ private static string HttpContextSlotName = GetHttpContextSlotName();
+
+ private static string GetHttpContextSlotName()
+ {
+ FieldInfo fi = typeof(HttpContext).GetField("CallContextSlotName", BindingFlags.Static | BindingFlags.NonPublic);
+
+ if (fi != null)
+ {
+ return (string) fi.GetValue(null);
+ }
+
+ return "HttpContext";
+ }
+
+ #endregion
+
+#region Private fields
+
+ private HttpContext _httpContext;
+ private LogicalCallContext _callContext;
+
+ #endregion
+
+ ///
+ /// Constructor
+ ///
+ private CallerThreadContext()
+ {
+ }
+
+ public bool CapturedCallContext
+ {
+ get
+ {
+ return (null != _callContext);
+ }
+ }
+
+ public bool CapturedHttpContext
+ {
+ get
+ {
+ return (null != _httpContext);
+ }
+ }
+
+ ///
+ /// Captures the current thread context
+ ///
+ ///
+ public static CallerThreadContext Capture(
+ bool captureCallContext,
+ bool captureHttpContext)
+ {
+ Debug.Assert(captureCallContext || captureHttpContext);
+
+ CallerThreadContext callerThreadContext = new CallerThreadContext();
+
+ // TODO: In NET 2.0, redo using the new feature of ExecutionContext class - Capture()
+ // Capture Call Context
+ if(captureCallContext && (getLogicalCallContextMethodInfo != null))
+ {
+ callerThreadContext._callContext = (LogicalCallContext)getLogicalCallContextMethodInfo.Invoke(Thread.CurrentThread, null);
+ if (callerThreadContext._callContext != null)
+ {
+ callerThreadContext._callContext = (LogicalCallContext)callerThreadContext._callContext.Clone();
+ }
+ }
+
+ // Capture httpContext
+ if (captureHttpContext && (null != HttpContext.Current))
+ {
+ callerThreadContext._httpContext = HttpContext.Current;
+ }
+
+ return callerThreadContext;
+ }
+
+ ///
+ /// Applies the thread context stored earlier
+ ///
+ ///
+ public static void Apply(CallerThreadContext callerThreadContext)
+ {
+ if (null == callerThreadContext)
+ {
+ throw new ArgumentNullException("callerThreadContext");
+ }
+
+ // Todo: In NET 2.0, redo using the new feature of ExecutionContext class - Run()
+ // Restore call context
+ if ((callerThreadContext._callContext != null) && (setLogicalCallContextMethodInfo != null))
+ {
+ setLogicalCallContextMethodInfo.Invoke(Thread.CurrentThread, new object[] { callerThreadContext._callContext });
+ }
+
+ // Restore HttpContext
+ if (callerThreadContext._httpContext != null)
+ {
+ HttpContext.Current = callerThreadContext._httpContext;
+ //CallContext.SetData(HttpContextSlotName, callerThreadContext._httpContext);
+ }
+ }
+ }
+
+ #endregion
+}
+#endif
diff --git a/ThirdParty/SmartThreadPool/CanceledWorkItemsGroup.cs b/ThirdParty/SmartThreadPool/CanceledWorkItemsGroup.cs
index 4a2a3e7..5752957 100644
--- a/ThirdParty/SmartThreadPool/CanceledWorkItemsGroup.cs
+++ b/ThirdParty/SmartThreadPool/CanceledWorkItemsGroup.cs
@@ -1,14 +1,14 @@
-namespace Amib.Threading.Internal
-{
- internal class CanceledWorkItemsGroup
- {
- public readonly static CanceledWorkItemsGroup NotCanceledWorkItemsGroup = new CanceledWorkItemsGroup();
-
- public CanceledWorkItemsGroup()
- {
- IsCanceled = false;
- }
-
- public bool IsCanceled { get; set; }
- }
+namespace Amib.Threading.Internal
+{
+ internal class CanceledWorkItemsGroup
+ {
+ public readonly static CanceledWorkItemsGroup NotCanceledWorkItemsGroup = new CanceledWorkItemsGroup();
+
+ public CanceledWorkItemsGroup()
+ {
+ IsCanceled = false;
+ }
+
+ public bool IsCanceled { get; set; }
+ }
}
\ No newline at end of file
diff --git a/ThirdParty/SmartThreadPool/EventWaitHandle.cs b/ThirdParty/SmartThreadPool/EventWaitHandle.cs
index 70a1a29..25be07a 100644
--- a/ThirdParty/SmartThreadPool/EventWaitHandle.cs
+++ b/ThirdParty/SmartThreadPool/EventWaitHandle.cs
@@ -1,104 +1,104 @@
-#if (_WINDOWS_CE)
-
-using System;
-using System.Runtime.InteropServices;
-using System.Threading;
-
-namespace Amib.Threading.Internal
-{
- ///
- /// EventWaitHandle class
- /// In WindowsCE this class doesn't exist and I needed the WaitAll and WaitAny implementation.
- /// So I wrote this class to implement these two methods with some of their overloads.
- /// It uses the WaitForMultipleObjects API to do the WaitAll and WaitAny.
- /// Note that this class doesn't even inherit from WaitHandle!
- ///
- public class STPEventWaitHandle
- {
- #region Public Constants
-
- public const int WaitTimeout = Timeout.Infinite;
-
- #endregion
-
- #region Private External Constants
-
- private const Int32 WAIT_FAILED = -1;
- private const Int32 WAIT_TIMEOUT = 0x102;
- private const UInt32 INFINITE = 0xFFFFFFFF;
-
- #endregion
-
- #region WaitAll and WaitAny
-
- internal static bool WaitOne(WaitHandle waitHandle, int millisecondsTimeout, bool exitContext)
- {
- return waitHandle.WaitOne(millisecondsTimeout, exitContext);
- }
-
- private static IntPtr[] PrepareNativeHandles(WaitHandle[] waitHandles)
- {
- IntPtr[] nativeHandles = new IntPtr[waitHandles.Length];
- for (int i = 0; i < waitHandles.Length; i++)
- {
- nativeHandles[i] = waitHandles[i].Handle;
- }
- return nativeHandles;
- }
-
- public static bool WaitAll(WaitHandle[] waitHandles, int millisecondsTimeout, bool exitContext)
- {
- uint timeout = millisecondsTimeout < 0 ? INFINITE : (uint)millisecondsTimeout;
-
- IntPtr[] nativeHandles = PrepareNativeHandles(waitHandles);
-
- int result = WaitForMultipleObjects((uint)waitHandles.Length, nativeHandles, true, timeout);
-
- if (result == WAIT_TIMEOUT || result == WAIT_FAILED)
- {
- return false;
- }
-
- return true;
- }
-
-
- public static int WaitAny(WaitHandle[] waitHandles, int millisecondsTimeout, bool exitContext)
- {
- uint timeout = millisecondsTimeout < 0 ? INFINITE : (uint)millisecondsTimeout;
-
- IntPtr[] nativeHandles = PrepareNativeHandles(waitHandles);
-
- int result = WaitForMultipleObjects((uint)waitHandles.Length, nativeHandles, false, timeout);
-
- if (result >= 0 && result < waitHandles.Length)
- {
- return result;
- }
-
- return -1;
- }
-
- public static int WaitAny(WaitHandle[] waitHandles)
- {
- return WaitAny(waitHandles, Timeout.Infinite, false);
- }
-
- public static int WaitAny(WaitHandle[] waitHandles, TimeSpan timeout, bool exitContext)
- {
- int millisecondsTimeout = (int)timeout.TotalMilliseconds;
-
- return WaitAny(waitHandles, millisecondsTimeout, false);
- }
-
- #endregion
-
- #region External methods
-
- [DllImport("coredll.dll", SetLastError = true)]
- public static extern int WaitForMultipleObjects(uint nCount, IntPtr[] lpHandles, bool fWaitAll, uint dwMilliseconds);
-
- #endregion
- }
-}
+#if (_WINDOWS_CE)
+
+using System;
+using System.Runtime.InteropServices;
+using System.Threading;
+
+namespace Amib.Threading.Internal
+{
+ ///
+ /// EventWaitHandle class
+ /// In WindowsCE this class doesn't exist and I needed the WaitAll and WaitAny implementation.
+ /// So I wrote this class to implement these two methods with some of their overloads.
+ /// It uses the WaitForMultipleObjects API to do the WaitAll and WaitAny.
+ /// Note that this class doesn't even inherit from WaitHandle!
+ ///
+ public class STPEventWaitHandle
+ {
+ #region Public Constants
+
+ public const int WaitTimeout = Timeout.Infinite;
+
+ #endregion
+
+ #region Private External Constants
+
+ private const Int32 WAIT_FAILED = -1;
+ private const Int32 WAIT_TIMEOUT = 0x102;
+ private const UInt32 INFINITE = 0xFFFFFFFF;
+
+ #endregion
+
+ #region WaitAll and WaitAny
+
+ internal static bool WaitOne(WaitHandle waitHandle, int millisecondsTimeout, bool exitContext)
+ {
+ return waitHandle.WaitOne(millisecondsTimeout, exitContext);
+ }
+
+ private static IntPtr[] PrepareNativeHandles(WaitHandle[] waitHandles)
+ {
+ IntPtr[] nativeHandles = new IntPtr[waitHandles.Length];
+ for (int i = 0; i < waitHandles.Length; i++)
+ {
+ nativeHandles[i] = waitHandles[i].Handle;
+ }
+ return nativeHandles;
+ }
+
+ public static bool WaitAll(WaitHandle[] waitHandles, int millisecondsTimeout, bool exitContext)
+ {
+ uint timeout = millisecondsTimeout < 0 ? INFINITE : (uint)millisecondsTimeout;
+
+ IntPtr[] nativeHandles = PrepareNativeHandles(waitHandles);
+
+ int result = WaitForMultipleObjects((uint)waitHandles.Length, nativeHandles, true, timeout);
+
+ if (result == WAIT_TIMEOUT || result == WAIT_FAILED)
+ {
+ return false;
+ }
+
+ return true;
+ }
+
+
+ public static int WaitAny(WaitHandle[] waitHandles, int millisecondsTimeout, bool exitContext)
+ {
+ uint timeout = millisecondsTimeout < 0 ? INFINITE : (uint)millisecondsTimeout;
+
+ IntPtr[] nativeHandles = PrepareNativeHandles(waitHandles);
+
+ int result = WaitForMultipleObjects((uint)waitHandles.Length, nativeHandles, false, timeout);
+
+ if (result >= 0 && result < waitHandles.Length)
+ {
+ return result;
+ }
+
+ return -1;
+ }
+
+ public static int WaitAny(WaitHandle[] waitHandles)
+ {
+ return WaitAny(waitHandles, Timeout.Infinite, false);
+ }
+
+ public static int WaitAny(WaitHandle[] waitHandles, TimeSpan timeout, bool exitContext)
+ {
+ int millisecondsTimeout = (int)timeout.TotalMilliseconds;
+
+ return WaitAny(waitHandles, millisecondsTimeout, false);
+ }
+
+ #endregion
+
+ #region External methods
+
+ [DllImport("coredll.dll", SetLastError = true)]
+ public static extern int WaitForMultipleObjects(uint nCount, IntPtr[] lpHandles, bool fWaitAll, uint dwMilliseconds);
+
+ #endregion
+ }
+}
#endif
\ No newline at end of file
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 @@
-using System.Threading;
-
-#if (_WINDOWS_CE)
-using System;
-using System.Runtime.InteropServices;
-#endif
-
-namespace Amib.Threading.Internal
-{
- ///
- /// EventWaitHandleFactory class.
- /// This is a static class that creates AutoResetEvent and ManualResetEvent objects.
- /// In WindowCE the WaitForMultipleObjects API fails to use the Handle property
- /// of XxxResetEvent. It can use only handles that were created by the CreateEvent API.
- /// Consequently this class creates the needed XxxResetEvent and replaces the handle if
- /// it's a WindowsCE OS.
- ///
- public static class EventWaitHandleFactory
- {
- ///
- /// Create a new AutoResetEvent object
- ///
- /// Return a new AutoResetEvent object
- public static AutoResetEvent CreateAutoResetEvent()
- {
- AutoResetEvent waitHandle = new AutoResetEvent(false);
-
-#if (_WINDOWS_CE)
- ReplaceEventHandle(waitHandle, false, false);
-#endif
-
- return waitHandle;
- }
-
- ///
- /// Create a new ManualResetEvent object
- ///
- /// Return a new ManualResetEvent object
- public static ManualResetEvent CreateManualResetEvent(bool initialState)
- {
- ManualResetEvent waitHandle = new ManualResetEvent(initialState);
-
-#if (_WINDOWS_CE)
- ReplaceEventHandle(waitHandle, true, initialState);
-#endif
-
- return waitHandle;
- }
-
-#if (_WINDOWS_CE)
-
- ///
- /// Replace the event handle
- ///
- /// The WaitHandle object which its handle needs to be replaced.
- /// Indicates if the event is a ManualResetEvent (true) or an AutoResetEvent (false)
- /// The initial state of the event
- private static void ReplaceEventHandle(WaitHandle waitHandle, bool manualReset, bool initialState)
- {
- // Store the old handle
- IntPtr oldHandle = waitHandle.Handle;
-
- // Create a new event
- IntPtr newHandle = CreateEvent(IntPtr.Zero, manualReset, initialState, null);
-
- // Replace the old event with the new event
- waitHandle.Handle = newHandle;
-
- // Close the old event
- CloseHandle (oldHandle);
- }
-
- [DllImport("coredll.dll", SetLastError = true)]
- public static extern IntPtr CreateEvent(IntPtr lpEventAttributes, bool bManualReset, bool bInitialState, string lpName);
-
- //Handle
- [DllImport("coredll.dll", SetLastError = true)]
- public static extern bool CloseHandle(IntPtr hObject);
-#endif
-
- }
-}
+using System.Threading;
+
+#if (_WINDOWS_CE)
+using System;
+using System.Runtime.InteropServices;
+#endif
+
+namespace Amib.Threading.Internal
+{
+ ///
+ /// EventWaitHandleFactory class.
+ /// This is a static class that creates AutoResetEvent and ManualResetEvent objects.
+ /// In WindowCE the WaitForMultipleObjects API fails to use the Handle property
+ /// of XxxResetEvent. It can use only handles that were created by the CreateEvent API.
+ /// Consequently this class creates the needed XxxResetEvent and replaces the handle if
+ /// it's a WindowsCE OS.
+ ///
+ public static class EventWaitHandleFactory
+ {
+ ///
+ /// Create a new AutoResetEvent object
+ ///
+ /// Return a new AutoResetEvent object
+ public static AutoResetEvent CreateAutoResetEvent()
+ {
+ AutoResetEvent waitHandle = new AutoResetEvent(false);
+
+#if (_WINDOWS_CE)
+ ReplaceEventHandle(waitHandle, false, false);
+#endif
+
+ return waitHandle;
+ }
+
+ ///
+ /// Create a new ManualResetEvent object
+ ///
+ /// Return a new ManualResetEvent object
+ public static ManualResetEvent CreateManualResetEvent(bool initialState)
+ {
+ ManualResetEvent waitHandle = new ManualResetEvent(initialState);
+
+#if (_WINDOWS_CE)
+ ReplaceEventHandle(waitHandle, true, initialState);
+#endif
+
+ return waitHandle;
+ }
+
+#if (_WINDOWS_CE)
+
+ ///
+ /// Replace the event handle
+ ///
+ /// The WaitHandle object which its handle needs to be replaced.
+ /// Indicates if the event is a ManualResetEvent (true) or an AutoResetEvent (false)
+ /// The initial state of the event
+ private static void ReplaceEventHandle(WaitHandle waitHandle, bool manualReset, bool initialState)
+ {
+ // Store the old handle
+ IntPtr oldHandle = waitHandle.Handle;
+
+ // Create a new event
+ IntPtr newHandle = CreateEvent(IntPtr.Zero, manualReset, initialState, null);
+
+ // Replace the old event with the new event
+ waitHandle.Handle = newHandle;
+
+ // Close the old event
+ CloseHandle (oldHandle);
+ }
+
+ [DllImport("coredll.dll", SetLastError = true)]
+ public static extern IntPtr CreateEvent(IntPtr lpEventAttributes, bool bManualReset, bool bInitialState, string lpName);
+
+ //Handle
+ [DllImport("coredll.dll", SetLastError = true)]
+ public static extern bool CloseHandle(IntPtr hObject);
+#endif
+
+ }
+}
diff --git a/ThirdParty/SmartThreadPool/Exceptions.cs b/ThirdParty/SmartThreadPool/Exceptions.cs
index 8e66ce9..6c6a88b 100644
--- a/ThirdParty/SmartThreadPool/Exceptions.cs
+++ b/ThirdParty/SmartThreadPool/Exceptions.cs
@@ -1,111 +1,111 @@
-using System;
-#if !(_WINDOWS_CE)
-using System.Runtime.Serialization;
-#endif
-
-namespace Amib.Threading
-{
- #region Exceptions
-
- ///
- /// Represents an exception in case IWorkItemResult.GetResult has been canceled
- ///
- public sealed partial class WorkItemCancelException : Exception
- {
- public WorkItemCancelException()
- {
- }
-
- public WorkItemCancelException(string message)
- : base(message)
- {
- }
-
- public WorkItemCancelException(string message, Exception e)
- : base(message, e)
- {
- }
- }
-
- ///
- /// Represents an exception in case IWorkItemResult.GetResult has been timed out
- ///
- public sealed partial class WorkItemTimeoutException : Exception
- {
- public WorkItemTimeoutException()
- {
- }
-
- public WorkItemTimeoutException(string message)
- : base(message)
- {
- }
-
- public WorkItemTimeoutException(string message, Exception e)
- : base(message, e)
- {
- }
- }
-
- ///
- /// Represents an exception in case IWorkItemResult.GetResult has been timed out
- ///
- public sealed partial class WorkItemResultException : Exception
- {
- public WorkItemResultException()
- {
- }
-
- public WorkItemResultException(string message)
- : base(message)
- {
- }
-
- public WorkItemResultException(string message, Exception e)
- : base(message, e)
- {
- }
- }
-
-
-#if !(_WINDOWS_CE) && !(_SILVERLIGHT) && !(WINDOWS_PHONE)
- ///
- /// Represents an exception in case IWorkItemResult.GetResult has been canceled
- ///
- [Serializable]
- public sealed partial class WorkItemCancelException
- {
- public WorkItemCancelException(SerializationInfo si, StreamingContext sc)
- : base(si, sc)
- {
- }
- }
-
- ///
- /// Represents an exception in case IWorkItemResult.GetResult has been timed out
- ///
- [Serializable]
- public sealed partial class WorkItemTimeoutException
- {
- public WorkItemTimeoutException(SerializationInfo si, StreamingContext sc)
- : base(si, sc)
- {
- }
- }
-
- ///
- /// Represents an exception in case IWorkItemResult.GetResult has been timed out
- ///
- [Serializable]
- public sealed partial class WorkItemResultException
- {
- public WorkItemResultException(SerializationInfo si, StreamingContext sc)
- : base(si, sc)
- {
- }
- }
-
-#endif
-
- #endregion
-}
+using System;
+#if !(_WINDOWS_CE)
+using System.Runtime.Serialization;
+#endif
+
+namespace Amib.Threading
+{
+ #region Exceptions
+
+ ///
+ /// Represents an exception in case IWorkItemResult.GetResult has been canceled
+ ///
+ public sealed partial class WorkItemCancelException : Exception
+ {
+ public WorkItemCancelException()
+ {
+ }
+
+ public WorkItemCancelException(string message)
+ : base(message)
+ {
+ }
+
+ public WorkItemCancelException(string message, Exception e)
+ : base(message, e)
+ {
+ }
+ }
+
+ ///
+ /// Represents an exception in case IWorkItemResult.GetResult has been timed out
+ ///
+ public sealed partial class WorkItemTimeoutException : Exception
+ {
+ public WorkItemTimeoutException()
+ {
+ }
+
+ public WorkItemTimeoutException(string message)
+ : base(message)
+ {
+ }
+
+ public WorkItemTimeoutException(string message, Exception e)
+ : base(message, e)
+ {
+ }
+ }
+
+ ///
+ /// Represents an exception in case IWorkItemResult.GetResult has been timed out
+ ///
+ public sealed partial class WorkItemResultException : Exception
+ {
+ public WorkItemResultException()
+ {
+ }
+
+ public WorkItemResultException(string message)
+ : base(message)
+ {
+ }
+
+ public WorkItemResultException(string message, Exception e)
+ : base(message, e)
+ {
+ }
+ }
+
+
+#if !(_WINDOWS_CE) && !(_SILVERLIGHT) && !(WINDOWS_PHONE)
+ ///
+ /// Represents an exception in case IWorkItemResult.GetResult has been canceled
+ ///
+ [Serializable]
+ public sealed partial class WorkItemCancelException
+ {
+ public WorkItemCancelException(SerializationInfo si, StreamingContext sc)
+ : base(si, sc)
+ {
+ }
+ }
+
+ ///
+ /// Represents an exception in case IWorkItemResult.GetResult has been timed out
+ ///
+ [Serializable]
+ public sealed partial class WorkItemTimeoutException
+ {
+ public WorkItemTimeoutException(SerializationInfo si, StreamingContext sc)
+ : base(si, sc)
+ {
+ }
+ }
+
+ ///
+ /// Represents an exception in case IWorkItemResult.GetResult has been timed out
+ ///
+ [Serializable]
+ public sealed partial class WorkItemResultException
+ {
+ public WorkItemResultException(SerializationInfo si, StreamingContext sc)
+ : base(si, sc)
+ {
+ }
+ }
+
+#endif
+
+ #endregion
+}
diff --git a/ThirdParty/SmartThreadPool/Interfaces.cs b/ThirdParty/SmartThreadPool/Interfaces.cs
index 29c8a3e..513422f 100644
--- a/ThirdParty/SmartThreadPool/Interfaces.cs
+++ b/ThirdParty/SmartThreadPool/Interfaces.cs
@@ -1,628 +1,628 @@
-using System;
-using System.Threading;
-
-namespace Amib.Threading
-{
- #region Delegates
-
- ///
- /// A delegate that represents the method to run as the work item
- ///
- /// A state object for the method to run
- public delegate object WorkItemCallback(object state);
-
- ///
- /// A delegate to call after the WorkItemCallback completed
- ///
- /// The work item result object
- public delegate void PostExecuteWorkItemCallback(IWorkItemResult wir);
-
- ///
- /// A delegate to call after the WorkItemCallback completed
- ///
- /// The work item result object
- public delegate void PostExecuteWorkItemCallback(IWorkItemResult wir);
-
- ///
- /// A delegate to call when a WorkItemsGroup becomes idle
- ///
- /// A reference to the WorkItemsGroup that became idle
- public delegate void WorkItemsGroupIdleHandler(IWorkItemsGroup workItemsGroup);
-
- ///
- /// A delegate to call after a thread is created, but before
- /// it's first use.
- ///
- public delegate void ThreadInitializationHandler();
-
- ///
- /// A delegate to call when a thread is about to exit, after
- /// it is no longer belong to the pool.
- ///
- public delegate void ThreadTerminationHandler();
-
- #endregion
-
- #region WorkItem Priority
-
- ///
- /// Defines the availeable priorities of a work item.
- /// The higher the priority a work item has, the sooner
- /// it will be executed.
- ///
- public enum WorkItemPriority
- {
- Lowest,
- BelowNormal,
- Normal,
- AboveNormal,
- Highest,
- }
-
- #endregion
-
- #region IWorkItemsGroup interface
-
- ///
- /// IWorkItemsGroup interface
- /// Created by SmartThreadPool.CreateWorkItemsGroup()
- ///
- public interface IWorkItemsGroup
- {
- ///
- /// Get/Set the name of the WorkItemsGroup
- ///
- string Name { get; set; }
-
- ///
- /// Get/Set the maximum number of workitem that execute cocurrency on the thread pool
- ///
- int Concurrency { get; set; }
-
- ///
- /// Get the number of work items waiting in the queue.
- ///
- int WaitingCallbacks { get; }
-
- ///
- /// Get an array with all the state objects of the currently running items.
- /// The array represents a snap shot and impact performance.
- ///
- object[] GetStates();
-
- ///
- /// Get the WorkItemsGroup start information
- ///
- WIGStartInfo WIGStartInfo { get; }
-
- ///
- /// Starts to execute work items
- ///
- void Start();
-
- ///
- /// Cancel all the work items.
- /// Same as Cancel(false)
- ///
- void Cancel();
-
- ///
- /// Cancel all work items using thread abortion
- ///
- /// True to stop work items by raising ThreadAbortException
- void Cancel(bool abortExecution);
-
- ///
- /// Wait for all work item to complete.
- ///
- void WaitForIdle();
-
- ///
- /// Wait for all work item to complete, until timeout expired
- ///
- /// How long to wait for the work items to complete
- /// Returns true if work items completed within the timeout, otherwise false.
- bool WaitForIdle(TimeSpan timeout);
-
- ///
- /// Wait for all work item to complete, until timeout expired
- ///
- /// How long to wait for the work items to complete in milliseconds
- /// Returns true if work items completed within the timeout, otherwise false.
- bool WaitForIdle(int millisecondsTimeout);
-
- ///
- /// IsIdle is true when there are no work items running or queued.
- ///
- bool IsIdle { get; }
-
- ///
- /// This event is fired when all work items are completed.
- /// (When IsIdle changes to true)
- /// This event only work on WorkItemsGroup. On SmartThreadPool
- /// it throws the NotImplementedException.
- ///
- event WorkItemsGroupIdleHandler OnIdle;
-
- #region QueueWorkItem
-
- ///
- /// Queue a work item
- ///
- /// A callback to execute
- /// Returns a work item result
- IWorkItemResult QueueWorkItem(WorkItemCallback callback);
-
- ///
- /// Queue a work item
- ///
- /// A callback to execute
- /// The priority of the work item
- /// Returns a work item result
- IWorkItemResult QueueWorkItem(WorkItemCallback callback, WorkItemPriority workItemPriority);
-
- ///
- /// Queue a work item
- ///
- /// A callback to execute
- ///
- /// The context object of the work item. Used for passing arguments to the work item.
- ///
- /// Returns a work item result
- IWorkItemResult QueueWorkItem(WorkItemCallback callback, object state);
-
- ///
- /// Queue a work item
- ///
- /// A callback to execute
- ///
- /// The context object of the work item. Used for passing arguments to the work item.
- ///
- /// The work item priority
- /// Returns a work item result
- IWorkItemResult QueueWorkItem(WorkItemCallback callback, object state, WorkItemPriority workItemPriority);
-
- ///
- /// Queue a work item
- ///
- /// A callback to execute
- ///
- /// The context object of the work item. Used for passing arguments to the work item.
- ///
- ///
- /// A delegate to call after the callback completion
- ///
- /// Returns a work item result
- IWorkItemResult QueueWorkItem(WorkItemCallback callback, object state, PostExecuteWorkItemCallback postExecuteWorkItemCallback);
-
- ///
- /// Queue a work item
- ///
- /// A callback to execute
- ///
- /// The context object of the work item. Used for passing arguments to the work item.
- ///
- ///
- /// A delegate to call after the callback completion
- ///
- /// The work item priority
- /// Returns a work item result
- IWorkItemResult QueueWorkItem(WorkItemCallback callback, object state, PostExecuteWorkItemCallback postExecuteWorkItemCallback, WorkItemPriority workItemPriority);
-
- ///
- /// Queue a work item
- ///
- /// A callback to execute
- ///
- /// The context object of the work item. Used for passing arguments to the work item.
- ///
- ///
- /// A delegate to call after the callback completion
- ///
- /// Indicates on which cases to call to the post execute callback
- /// Returns a work item result
- IWorkItemResult QueueWorkItem(WorkItemCallback callback, object state, PostExecuteWorkItemCallback postExecuteWorkItemCallback, CallToPostExecute callToPostExecute);
-
- ///
- /// Queue a work item
- ///
- /// A callback to execute
- ///
- /// The context object of the work item. Used for passing arguments to the work item.
- ///
- ///
- /// A delegate to call after the callback completion
- ///
- /// Indicates on which cases to call to the post execute callback
- /// The work item priority
- /// Returns a work item result
- IWorkItemResult QueueWorkItem(WorkItemCallback callback, object state, PostExecuteWorkItemCallback postExecuteWorkItemCallback, CallToPostExecute callToPostExecute, WorkItemPriority workItemPriority);
-
- ///
- /// Queue a work item
- ///
- /// Work item info
- /// A callback to execute
- /// Returns a work item result
- IWorkItemResult QueueWorkItem(WorkItemInfo workItemInfo, WorkItemCallback callback);
-
- ///
- /// Queue a work item
- ///
- /// Work item information
- /// A callback to execute
- ///
- /// The context object of the work item. Used for passing arguments to the work item.
- ///
- /// Returns a work item result
- IWorkItemResult QueueWorkItem(WorkItemInfo workItemInfo, WorkItemCallback callback, object state);
-
- #endregion
-
- #region QueueWorkItem(Action<...>)
-
- ///
- /// Queue a work item.
- ///
- /// Returns a IWorkItemResult object, but its GetResult() will always return null
- IWorkItemResult QueueWorkItem(Action action);
-
- ///
- /// Queue a work item.
- ///
- /// Returns a IWorkItemResult object, but its GetResult() will always return null
- IWorkItemResult QueueWorkItem (Action action, WorkItemPriority priority);
-
- ///
- /// Queue a work item.
- ///
- /// Returns a IWorkItemResult object, but its GetResult() will always return null
- IWorkItemResult QueueWorkItem (Action action, T arg, WorkItemPriority priority);
-
- ///
- /// Queue a work item.
- ///
- /// Returns a IWorkItemResult object, but its GetResult() will always return null
- IWorkItemResult QueueWorkItem (Action action, T arg);
-
- ///
- /// Queue a work item.
- ///
- /// Returns a IWorkItemResult object, but its GetResult() will always return null
- IWorkItemResult QueueWorkItem(Action action, T1 arg1, T2 arg2);
-
- ///
- /// Queue a work item.
- ///
- /// Returns a IWorkItemResult object, but its GetResult() will always return null
- IWorkItemResult QueueWorkItem (Action action, T1 arg1, T2 arg2, WorkItemPriority priority);
-
- ///
- /// Queue a work item.
- ///
- /// Returns a IWorkItemResult object, but its GetResult() will always return null
- IWorkItemResult QueueWorkItem(Action action, T1 arg1, T2 arg2, T3 arg3);
-
- ///
- /// Queue a work item.
- ///
- /// Returns a IWorkItemResult object, but its GetResult() will always return null
- IWorkItemResult QueueWorkItem (Action action, T1 arg1, T2 arg2, T3 arg3, WorkItemPriority priority);
-
- ///
- /// Queue a work item.
- ///
- /// Returns a IWorkItemResult object, but its GetResult() will always return null
- IWorkItemResult QueueWorkItem(Action action, T1 arg1, T2 arg2, T3 arg3, T4 arg4);
-
- ///
- /// Queue a work item.
- ///
- /// Returns a IWorkItemResult object, but its GetResult() will always return null
- IWorkItemResult QueueWorkItem (Action action, T1 arg1, T2 arg2, T3 arg3, T4 arg4, WorkItemPriority priority);
-
- #endregion
-
- #region QueueWorkItem(Func<...>)
-
- ///
- /// Queue a work item.
- ///
- /// Returns a IWorkItemResult<TResult> object.
- /// its GetResult() returns a TResult object
- IWorkItemResult QueueWorkItem(Func func);
-
- ///
- /// Queue a work item.
- ///
- /// Returns a IWorkItemResult<TResult> object.
- /// its GetResult() returns a TResult object
- IWorkItemResult QueueWorkItem(Func func, T arg);
-
- ///
- /// Queue a work item.
- ///
- /// Returns a IWorkItemResult<TResult> object.
- /// its GetResult() returns a TResult object
- IWorkItemResult QueueWorkItem(Func func, T1 arg1, T2 arg2);
-
- ///
- /// Queue a work item.
- ///
- /// Returns a IWorkItemResult<TResult> object.
- /// its GetResult() returns a TResult object
- IWorkItemResult QueueWorkItem(Func func, T1 arg1, T2 arg2, T3 arg3);
-
- ///
- /// Queue a work item.
- ///
- /// Returns a IWorkItemResult<TResult> object.
- /// its GetResult() returns a TResult object
- IWorkItemResult QueueWorkItem(Func func, T1 arg1, T2 arg2, T3 arg3, T4 arg4);
-
- #endregion
- }
-
- #endregion
-
- #region CallToPostExecute enumerator
-
- [Flags]
- public enum CallToPostExecute
- {
- ///
- /// Never call to the PostExecute call back
- ///
- Never = 0x00,
-
- ///
- /// Call to the PostExecute only when the work item is cancelled
- ///
- WhenWorkItemCanceled = 0x01,
-
- ///
- /// Call to the PostExecute only when the work item is not cancelled
- ///
- WhenWorkItemNotCanceled = 0x02,
-
- ///
- /// Always call to the PostExecute
- ///
- Always = WhenWorkItemCanceled | WhenWorkItemNotCanceled,
- }
-
- #endregion
-
- #region IWorkItemResult interface
-
- ///
- /// The common interface of IWorkItemResult and IWorkItemResult<T>
- ///
- public interface IWaitableResult
- {
- ///
- /// This method intent is for internal use.
- ///
- ///
- IWorkItemResult GetWorkItemResult();
-
- ///
- /// This method intent is for internal use.
- ///
- ///
- IWorkItemResult GetWorkItemResultT();
- }
-
- ///
- /// IWorkItemResult interface.
- /// Created when a WorkItemCallback work item is queued.
- ///
- public interface IWorkItemResult : IWorkItemResult