-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Reduce ExecutionContext register handling code size #21908
Conversation
|
A little more with next commit
|
ExecutionContext currentExecutionCtx = currentThread.ExecutionContext; | ||
if (previousExecutionCtx != currentExecutionCtx) | ||
{ | ||
ExecutionContext.RestoreChangedContextToThread(currentThread, previousExecutionCtx, currentExecutionCtx); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This part (moving a part of the less common logic into non-generic ExecutionContext.RestoreChangedContextToThread) looks good to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let me do that as by itself as a fresh PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -1064,6 +1048,29 @@ internal static void ThrowAsync(Exception exception, SynchronizationContext targ | |||
} | |||
} | |||
|
|||
private static ExceptionDispatchInfo RunReturningAnyException<TStateMachine>(ref TStateMachine stateMachine) where TStateMachine : IAsyncStateMachine |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This extra generic method is questionable because of the extra runtime metadata that comes with every generic method.
I think there is a good idea here to just have a small try/catch instead of finally. What would the gains look like if the same small try/catch is inline in the caller?
Will revisit post #21909 |
Brought up in #21875 (comment)
Remove executing on the ExecutionContext with error handling out of flow to
RunReturningAnyException
methods; away from setting and restoring ExecutionContext to reduce the need for manual enregistering workarounds.https://github.com/dotnet/coreclr/pull/21908/files?w=1
/cc @stephentoub @jkotas not sure if this is a help or hindrance?