From 206fb306a7820cf593570e35ddfa8e7c5a10e449 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 1 May 2013 19:01:43 +0100 Subject: Update SmartThreadPool to latest version 2.2.3 with a major and minor change. SmartThreadPool code comes from http://www.codeproject.com/Articles/7933/Smart-Thread-Pool This version implements thread abort (via WorkItem.Cancel(true)), threadpool naming, max thread stack, etc. so we no longer need to manually patch those. However, two changes have been made to stock 2.2.3. Major change: WorkItem.Cancel(bool abortExecution) in our version does not succeed if the work item was in progress and thread abort was not specified. This is to match previous behaviour where we handle co-operative termination via another mechanism rather than checking WorkItem.IsCanceled. Minor change: Did not add STP's StopWatch implementation as this is only used WinCE and Silverlight and causes a build clash with System.Diagnostics.StopWatch The reason for updating is to see if this improves http://opensimulator.org/mantis/view.php?id=6557 and http://opensimulator.org/mantis/view.php?id=6586 --- ThirdParty/SmartThreadPool/WorkItemInfo.cs | 171 ++++++++++++----------------- 1 file changed, 69 insertions(+), 102 deletions(-) (limited to 'ThirdParty/SmartThreadPool/WorkItemInfo.cs') diff --git a/ThirdParty/SmartThreadPool/WorkItemInfo.cs b/ThirdParty/SmartThreadPool/WorkItemInfo.cs index c259339..5fbceb8 100644 --- a/ThirdParty/SmartThreadPool/WorkItemInfo.cs +++ b/ThirdParty/SmartThreadPool/WorkItemInfo.cs @@ -1,102 +1,69 @@ -// Ami Bar -// amibar@gmail.com - -namespace Amib.Threading -{ - #region WorkItemInfo class - - /// - /// Summary description for WorkItemInfo. - /// - public class WorkItemInfo - { - /// - /// Use the caller's security context - /// - private bool _useCallerCallContext; - - /// - /// Use the caller's security context - /// - private bool _useCallerHttpContext; - - /// - /// Dispose of the state object of a work item - /// - private bool _disposeOfStateObjects; - - /// - /// The option to run the post execute - /// - private CallToPostExecute _callToPostExecute; - - /// - /// A post execute callback to call when none is provided in - /// the QueueWorkItem method. - /// - private PostExecuteWorkItemCallback _postExecuteWorkItemCallback; - - /// - /// The priority of the work item - /// - private WorkItemPriority _workItemPriority; - - public WorkItemInfo() - { - _useCallerCallContext = SmartThreadPool.DefaultUseCallerCallContext; - _useCallerHttpContext = SmartThreadPool.DefaultUseCallerHttpContext; - _disposeOfStateObjects = SmartThreadPool.DefaultDisposeOfStateObjects; - _callToPostExecute = SmartThreadPool.DefaultCallToPostExecute; - _postExecuteWorkItemCallback = SmartThreadPool.DefaultPostExecuteWorkItemCallback; - _workItemPriority = SmartThreadPool.DefaultWorkItemPriority; - } - - public WorkItemInfo(WorkItemInfo workItemInfo) - { - _useCallerCallContext = workItemInfo._useCallerCallContext; - _useCallerHttpContext = workItemInfo._useCallerHttpContext; - _disposeOfStateObjects = workItemInfo._disposeOfStateObjects; - _callToPostExecute = workItemInfo._callToPostExecute; - _postExecuteWorkItemCallback = workItemInfo._postExecuteWorkItemCallback; - _workItemPriority = workItemInfo._workItemPriority; - } - - public bool UseCallerCallContext - { - get { return _useCallerCallContext; } - set { _useCallerCallContext = value; } - } - - public bool UseCallerHttpContext - { - get { return _useCallerHttpContext; } - set { _useCallerHttpContext = value; } - } - - public bool DisposeOfStateObjects - { - get { return _disposeOfStateObjects; } - set { _disposeOfStateObjects = value; } - } - - public CallToPostExecute CallToPostExecute - { - get { return _callToPostExecute; } - set { _callToPostExecute = value; } - } - - public PostExecuteWorkItemCallback PostExecuteWorkItemCallback - { - get { return _postExecuteWorkItemCallback; } - set { _postExecuteWorkItemCallback = value; } - } - - public WorkItemPriority WorkItemPriority - { - get { return _workItemPriority; } - set { _workItemPriority = value; } - } - } - - #endregion -} +namespace Amib.Threading +{ + #region WorkItemInfo class + + /// + /// Summary description for WorkItemInfo. + /// + public class WorkItemInfo + { + public WorkItemInfo() + { + UseCallerCallContext = SmartThreadPool.DefaultUseCallerCallContext; + UseCallerHttpContext = SmartThreadPool.DefaultUseCallerHttpContext; + DisposeOfStateObjects = SmartThreadPool.DefaultDisposeOfStateObjects; + CallToPostExecute = SmartThreadPool.DefaultCallToPostExecute; + PostExecuteWorkItemCallback = SmartThreadPool.DefaultPostExecuteWorkItemCallback; + WorkItemPriority = SmartThreadPool.DefaultWorkItemPriority; + } + + public WorkItemInfo(WorkItemInfo workItemInfo) + { + UseCallerCallContext = workItemInfo.UseCallerCallContext; + UseCallerHttpContext = workItemInfo.UseCallerHttpContext; + DisposeOfStateObjects = workItemInfo.DisposeOfStateObjects; + CallToPostExecute = workItemInfo.CallToPostExecute; + PostExecuteWorkItemCallback = workItemInfo.PostExecuteWorkItemCallback; + WorkItemPriority = workItemInfo.WorkItemPriority; + Timeout = workItemInfo.Timeout; + } + + /// + /// Get/Set if to use the caller's security context + /// + public bool UseCallerCallContext { get; set; } + + /// + /// Get/Set if to use the caller's HTTP context + /// + public bool UseCallerHttpContext { get; set; } + + /// + /// Get/Set if to dispose of the state object of a work item + /// + public bool DisposeOfStateObjects { get; set; } + + /// + /// Get/Set the run the post execute options + /// + public CallToPostExecute CallToPostExecute { get; set; } + + /// + /// Get/Set the post execute callback + /// + public PostExecuteWorkItemCallback PostExecuteWorkItemCallback { get; set; } + + /// + /// Get/Set the work item's priority + /// + public WorkItemPriority WorkItemPriority { get; set; } + + /// + /// Get/Set the work item's timout in milliseconds. + /// This is a passive timout. When the timout expires the work item won't be actively aborted! + /// + public long Timeout { get; set; } + } + + #endregion +} -- cgit v1.1