diff options
author | Stephen Toub <stoub@microsoft.com> | 2018-03-16 14:10:36 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-03-16 14:10:36 -0400 |
commit | df996e2e64a88463169f523a2b5542730116b4fb (patch) | |
tree | b7caf2ddda6cf089f8abc258d7a40a290ebcce84 | |
parent | 6f2b94e5dac04a7246f20889af3765f202de4fdb (diff) | |
download | coreclr-df996e2e64a88463169f523a2b5542730116b4fb.tar.gz coreclr-df996e2e64a88463169f523a2b5542730116b4fb.tar.bz2 coreclr-df996e2e64a88463169f523a2b5542730116b4fb.zip |
Avoid allocating _IOCompletionCallback when flow is suppressed (#16984)
This delegate was showing up in a sockets allocation trace, even though execution flow is suppressed while creating the associated PreAllocatedOverlapped.
-rw-r--r-- | src/mscorlib/src/System/Threading/Overlapped.cs | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/mscorlib/src/System/Threading/Overlapped.cs b/src/mscorlib/src/System/Threading/Overlapped.cs index f4c6a603b5..8df01923d3 100644 --- a/src/mscorlib/src/System/Threading/Overlapped.cs +++ b/src/mscorlib/src/System/Threading/Overlapped.cs @@ -64,11 +64,10 @@ namespace System.Threading private uint _numBytes; // No. of bytes transferred private NativeOverlapped* _pOVERLAP; - internal _IOCompletionCallback(IOCompletionCallback ioCompletionCallback) + internal _IOCompletionCallback(IOCompletionCallback ioCompletionCallback, ExecutionContext executionContext) { _ioCompletionCallback = ioCompletionCallback; - // clone the exection context - _executionContext = ExecutionContext.Capture(); + _executionContext = executionContext; } // Context callback: same sig for SendOrPostCallback and ContextCallback internal static ContextCallback _ccb = new ContextCallback(IOCompletionCallback_Context); @@ -170,7 +169,8 @@ namespace System.Threading if (iocb != null) { - m_iocbHelper = new _IOCompletionCallback(iocb); + ExecutionContext ec = ExecutionContext.Capture(); + m_iocbHelper = ec != null ? new _IOCompletionCallback(iocb, ec) : null; m_iocb = iocb; } else |