diff --git a/Docs/SmartThreadPool.html b/Docs/SmartThreadPool.html index 163fbc9..3ca2d68 100644 --- a/Docs/SmartThreadPool.html +++ b/Docs/SmartThreadPool.html @@ -1,4 +1,10 @@
+
See the history section at the bottom for changes.
@@ -40,6 +46,8 @@@@ -96,8 +104,11 @@Added new methods: Join, Choice, and Pipe. --
++ New features added in December 2009
+What about the .NET ThreadPool?
The Windows system provides one .NET ThreadPool for each process. The .NET ThreadPool can contain up to 25 (by default) threads per processor. It is also stated that the operations in .NET ThreadPool should be quick to avoid suspension of the work of others who use the .NET ThreadPool. Note that several AppDomains in the same process share the same .NET ThreadPool. If you want a thread to work for a long period of time, then the .NET ThreadPool is not a good choice for you (unless you know what you are doing). Note that each asynchronous method call from the .NET Framework that begins with "Begin…" (e.g.,
BeginInvoke,BeginSend,BeginReceive, etc.) uses the .NET ThreadPool to run its callback. Also note that the .NET ThreadPool doesn't support calls to COM with single threaded apartment (STA), since the ThreadPool @@ -397,7 +408,7 @@ SmartThreadPool.WaitAny(new IWaitableResult[] { wir1, wir2});There is no guarantee that a work item will be cancelled, it depends on the state of the work item when the cancel is called and the cooperation of the work item. - (Note the work item's state I mention here has nothing to do with the state object + (Note that the work item's state I mention here has nothing to do with the state object argument provided in the
QueueWorkItem).These are the possible states of a work item: (defined in the
WorkItemStateenum)
@@ -747,6 +758,13 @@ to simplfy the initiation of a parallel task.Choice - Executes several work items and returns when the first one completes. (Choice example) Pipe - Executes several work items sequently and wait until the last work item completes. (Pipe example) ++
Work item timeout (passive) +This featue let the user specify a timeout for the work item in milliseconds. When the timeout expires the work item is cancelled + automatically. The cancel works the same as a call to Cancel with the
+abortExecutionargument set to false (This is why the timeout is passive).To sample the cancel use
+SmartThreadPool.IsWorkItemCanceledwhich is a static property, or you can useSmartThreadPool.AbortOnWorkItemOnCancel+which check if the current work item is cancelled and if so abort the thread (Thread.CurrentThread.Abort()).When to use?
The Smart Thread Pool is good when your work items don't do too much, but wait for events, IOs, sockets, etc. This means that the work items don't use CPU, but run for a long time. It is also good when you don't need to keep alive too many threads in the air all the time. If your work items do a short time work, then use the .NET ThreadPool. If you have a constant heavy load of work, then use Toub's thread pool and define the maximum number of threads accordingly.
@@ -1348,16 +1366,20 @@ public class PipeExampleAdded support for WinCE Added support for Action<T> and Func<T> -7th April 2009: Changes - + 7th April 2009: Changes +-
- Added support for Silverlight and Mono.
-- Added Join, Choice, and Pipe to SmartThreadPool.
-- Added local performance counters (for Mono, Silverlight, and WindowsCE)
-- Changed duration measures from DateTime.Now to Stopwatch.
-- Queues changed from System.Collections.Queue to System.Collections.Generic.LinkedList<T>.
+- Added support for Silverlight and Mono.
+- Added Join, Choice, and Pipe to SmartThreadPool.
+- Added local performance counters (for Mono, Silverlight, and WindowsCE)
+- Changed duration measures from DateTime.Now to Stopwatch.
+- Queues changed from System.Collections.Queue to System.Collections.Generic.LinkedList<T>.
21st December 2009: Changes + diff --git a/STPSLDemo/STPSLDemo.csproj b/STPSLDemo/STPSLDemo.csproj index ffa16d9..db7e8cf 100644 --- a/STPSLDemo/STPSLDemo.csproj +++ b/STPSLDemo/STPSLDemo.csproj @@ -23,6 +23,11 @@+
+- Added work item timeout (passive).
+true true false ++ +3.5 ++ true @@ -75,27 +80,28 @@- MSBuild:MarkupCompilePass1 +MSBuild:Compile +Designer - MSBuild:MarkupCompilePass1 +MSBuild:Compile Designer - MSBuild:MarkupCompilePass1 +MSBuild:Compile Designer - Page -MSBuild:MarkupCompilePass1 +Designer +MSBuild:Compile - Page -MSBuild:MarkupCompilePass1 +Designer +MSBuild:Compile - Page -MSBuild:MarkupCompilePass1 +Designer +MSBuild:Compile @@ -122,7 +128,7 @@ -PreserveNewest +