Browse Source

smartthreadpool: httpcontext will be gone (we dont use it)

UbitUmarov 3 years ago
parent
commit
b667bff8bb

+ 2 - 40
ThirdParty/SmartThreadPool/CallerThreadContext.cs

@@ -28,25 +28,10 @@ namespace Amib.Threading.Internal
         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
@@ -66,23 +51,13 @@ namespace Amib.Threading.Internal
             }
         }
 
-        public bool CapturedHttpContext
-        {
-            get
-            {
-                return (null != _httpContext);
-            }
-        }
-
         /// <summary>
         /// Captures the current thread context
         /// </summary>
         /// <returns></returns>
-        public static CallerThreadContext Capture(
-            bool captureCallContext,
-            bool captureHttpContext)
+        public static CallerThreadContext Capture(bool captureCallContext)
         {
-            Debug.Assert(captureCallContext || captureHttpContext);
+            Debug.Assert(captureCallContext);
 
             CallerThreadContext callerThreadContext = new CallerThreadContext();
 
@@ -97,12 +72,6 @@ namespace Amib.Threading.Internal
                 }
             }
 
-            // Capture httpContext
-            if (captureHttpContext && (null != HttpContext.Current))
-            {
-                callerThreadContext._httpContext = HttpContext.Current;
-            }
-
             return callerThreadContext;
         }
 
@@ -123,13 +92,6 @@ namespace Amib.Threading.Internal
             {
                 setLogicalCallContextMethodInfo.Invoke(Thread.CurrentThread, new object[] { callerThreadContext._callContext });
             }
-
-            // Restore HttpContext 
-            if (callerThreadContext._httpContext != null)
-            {
-                HttpContext.Current = callerThreadContext._httpContext;
-                //CallContext.SetData(HttpContextSlotName, callerThreadContext._httpContext);
-            }
         }
     }
 

+ 0 - 6
ThirdParty/SmartThreadPool/SmartThreadPool.cs

@@ -47,7 +47,6 @@
 //        - Added option to start the STP and the WIG as suspended
 //        - Exception behavior changed, the real exception is returned by an 
 //          inner exception
-//        - Added option to keep the Http context of the caller thread. (Thanks to Steven T.)
 //        - Added performance counters
 //        - Added priority to the threads in the pool
 //
@@ -136,11 +135,6 @@ namespace Amib.Threading
         /// </summary>
         public const bool DefaultUseCallerCallContext = false;
 
-        /// <summary>
-        /// Indicate to copy the HTTP context of the caller and then use it in the call. (false)
-        /// </summary>
-        public const bool DefaultUseCallerHttpContext = false;
-
         /// <summary>
         /// Indicate to dispose of the state objects if they support the IDispose interface. (false)
         /// </summary>

+ 0 - 17
ThirdParty/SmartThreadPool/WIGStartInfo.cs

@@ -8,7 +8,6 @@ namespace Amib.Threading
     public class WIGStartInfo
     {
         private bool _useCallerCallContext;
-        private bool _useCallerHttpContext;
         private bool _disposeOfStateObjects;
         private CallToPostExecute _callToPostExecute;
         private PostExecuteWorkItemCallback _postExecuteWorkItemCallback;
@@ -26,14 +25,12 @@ namespace Amib.Threading
             _postExecuteWorkItemCallback = SmartThreadPool.DefaultPostExecuteWorkItemCallback;
             _callToPostExecute = SmartThreadPool.DefaultCallToPostExecute;
             _disposeOfStateObjects = SmartThreadPool.DefaultDisposeOfStateObjects;
-            _useCallerHttpContext = SmartThreadPool.DefaultUseCallerHttpContext;
             _useCallerCallContext = SmartThreadPool.DefaultUseCallerCallContext;
         }
 
         public WIGStartInfo(WIGStartInfo wigStartInfo)
         {
             _useCallerCallContext = wigStartInfo.UseCallerCallContext;
-            _useCallerHttpContext = wigStartInfo.UseCallerHttpContext;
             _disposeOfStateObjects = wigStartInfo.DisposeOfStateObjects;
             _callToPostExecute = wigStartInfo.CallToPostExecute;
             _postExecuteWorkItemCallback = wigStartInfo.PostExecuteWorkItemCallback;
@@ -64,20 +61,6 @@ namespace Amib.Threading
         }
 
 
-        /// <summary>
-        /// Get/Set if to use the caller's HTTP context
-        /// </summary>
-        public virtual bool UseCallerHttpContext
-        {
-            get { return _useCallerHttpContext; }
-            set 
-            { 
-                ThrowIfReadOnly();  
-                _useCallerHttpContext = value; 
-            }
-        }
-
-
         /// <summary>
         /// Get/Set if to dispose of the state object of a work item
         /// </summary>

+ 3 - 3
ThirdParty/SmartThreadPool/WorkItem.cs

@@ -208,9 +208,9 @@ namespace Amib.Threading.Internal
             _workItemsGroup = workItemsGroup;
             _workItemInfo = workItemInfo;
 
-            if (_workItemInfo.UseCallerCallContext || _workItemInfo.UseCallerHttpContext)
+            if (_workItemInfo.UseCallerCallContext)
             {
-                _callerContext = CallerThreadContext.Capture(_workItemInfo.UseCallerCallContext, _workItemInfo.UseCallerHttpContext);
+                _callerContext = CallerThreadContext.Capture(_workItemInfo.UseCallerCallContext);
             }
 
             _callback = callback;
@@ -359,7 +359,7 @@ namespace Amib.Threading.Internal
             CallerThreadContext ctc = null;
             if (null != _callerContext)
             {
-                ctc = CallerThreadContext.Capture(_callerContext.CapturedCallContext, _callerContext.CapturedHttpContext);
+                ctc = CallerThreadContext.Capture(_callerContext.CapturedCallContext);
                 CallerThreadContext.Apply(_callerContext);
             }
 

+ 0 - 6
ThirdParty/SmartThreadPool/WorkItemFactory.cs

@@ -80,7 +80,6 @@ namespace Amib.Threading.Internal
             
             WorkItemInfo workItemInfo = new WorkItemInfo();
             workItemInfo.UseCallerCallContext = wigStartInfo.UseCallerCallContext;
-            workItemInfo.UseCallerHttpContext = wigStartInfo.UseCallerHttpContext;
             workItemInfo.PostExecuteWorkItemCallback = wigStartInfo.PostExecuteWorkItemCallback;
             workItemInfo.CallToPostExecute = wigStartInfo.CallToPostExecute;
             workItemInfo.DisposeOfStateObjects = wigStartInfo.DisposeOfStateObjects;
@@ -116,7 +115,6 @@ namespace Amib.Threading.Internal
 
             WorkItemInfo workItemInfo = new WorkItemInfo();
             workItemInfo.UseCallerCallContext = wigStartInfo.UseCallerCallContext;
-            workItemInfo.UseCallerHttpContext = wigStartInfo.UseCallerHttpContext;
             workItemInfo.PostExecuteWorkItemCallback = wigStartInfo.PostExecuteWorkItemCallback;
             workItemInfo.CallToPostExecute = wigStartInfo.CallToPostExecute;
             workItemInfo.DisposeOfStateObjects = wigStartInfo.DisposeOfStateObjects;
@@ -186,7 +184,6 @@ namespace Amib.Threading.Internal
 
             WorkItemInfo workItemInfo = new WorkItemInfo();
             workItemInfo.UseCallerCallContext = wigStartInfo.UseCallerCallContext;
-            workItemInfo.UseCallerHttpContext = wigStartInfo.UseCallerHttpContext;
             workItemInfo.PostExecuteWorkItemCallback = postExecuteWorkItemCallback;
             workItemInfo.CallToPostExecute = wigStartInfo.CallToPostExecute;
             workItemInfo.DisposeOfStateObjects = wigStartInfo.DisposeOfStateObjects;
@@ -228,7 +225,6 @@ namespace Amib.Threading.Internal
 
             WorkItemInfo workItemInfo = new WorkItemInfo();
             workItemInfo.UseCallerCallContext = wigStartInfo.UseCallerCallContext;
-            workItemInfo.UseCallerHttpContext = wigStartInfo.UseCallerHttpContext;
             workItemInfo.PostExecuteWorkItemCallback = postExecuteWorkItemCallback;
             workItemInfo.CallToPostExecute = wigStartInfo.CallToPostExecute;
             workItemInfo.DisposeOfStateObjects = wigStartInfo.DisposeOfStateObjects;
@@ -270,7 +266,6 @@ namespace Amib.Threading.Internal
 
             WorkItemInfo workItemInfo = new WorkItemInfo();
             workItemInfo.UseCallerCallContext = wigStartInfo.UseCallerCallContext;
-            workItemInfo.UseCallerHttpContext = wigStartInfo.UseCallerHttpContext;
             workItemInfo.PostExecuteWorkItemCallback = postExecuteWorkItemCallback;
             workItemInfo.CallToPostExecute = callToPostExecute;
             workItemInfo.DisposeOfStateObjects = wigStartInfo.DisposeOfStateObjects;
@@ -315,7 +310,6 @@ namespace Amib.Threading.Internal
 
             WorkItemInfo workItemInfo = new WorkItemInfo();
             workItemInfo.UseCallerCallContext = wigStartInfo.UseCallerCallContext;
-            workItemInfo.UseCallerHttpContext = wigStartInfo.UseCallerHttpContext;
             workItemInfo.PostExecuteWorkItemCallback = postExecuteWorkItemCallback;
             workItemInfo.CallToPostExecute = callToPostExecute;
             workItemInfo.WorkItemPriority = workItemPriority;

+ 0 - 7
ThirdParty/SmartThreadPool/WorkItemInfo.cs

@@ -10,7 +10,6 @@ namespace Amib.Threading
         public WorkItemInfo()
         {
             UseCallerCallContext = SmartThreadPool.DefaultUseCallerCallContext;
-            UseCallerHttpContext = SmartThreadPool.DefaultUseCallerHttpContext;
             DisposeOfStateObjects = SmartThreadPool.DefaultDisposeOfStateObjects;
             CallToPostExecute = SmartThreadPool.DefaultCallToPostExecute;
             PostExecuteWorkItemCallback = SmartThreadPool.DefaultPostExecuteWorkItemCallback;
@@ -20,7 +19,6 @@ namespace Amib.Threading
         public WorkItemInfo(WorkItemInfo workItemInfo)
         {
             UseCallerCallContext = workItemInfo.UseCallerCallContext;
-            UseCallerHttpContext = workItemInfo.UseCallerHttpContext;
             DisposeOfStateObjects = workItemInfo.DisposeOfStateObjects;
             CallToPostExecute = workItemInfo.CallToPostExecute;
             PostExecuteWorkItemCallback = workItemInfo.PostExecuteWorkItemCallback;
@@ -33,11 +31,6 @@ namespace Amib.Threading
         /// </summary>
         public bool UseCallerCallContext { get; set; }
 
-        /// <summary>
-        /// Get/Set if to use the caller's HTTP context
-        /// </summary>
-        public bool UseCallerHttpContext { get; set; }
-
         /// <summary>
         /// Get/Set if to dispose of the state object of a work item
         /// </summary>