diff options
author | Stephen Toub <stoub@microsoft.com> | 2019-10-17 11:32:29 -0400 |
---|---|---|
committer | Dan Moseley <danmose@microsoft.com> | 2019-10-17 08:32:29 -0700 |
commit | b9c739940772f2745e4fdf6c2951fd7c7d3c7be0 (patch) | |
tree | 065a72c620987d26abd421214b009f1ed1ac4198 /src | |
parent | 617091aa904c74fe8a42cebf7fcb56677c60c079 (diff) | |
download | coreclr-b9c739940772f2745e4fdf6c2951fd7c7d3c7be0.tar.gz coreclr-b9c739940772f2745e4fdf6c2951fd7c7d3c7be0.tar.bz2 coreclr-b9c739940772f2745e4fdf6c2951fd7c7d3c7be0.zip |
Enable ETW/EventSource logging of task IDs for boxed state machines (#27115) (#27217)
* Wrap MoveNext Action for TPL event tracing
Wraps the MoveNext action of the AsyncStateMachineBox in a
continuation wrapper when async causality tracing is on so that the
TPL event source can find the task that is associated with a
continuation. Does not wrap otherwise.
* Clarifying comment
* removing trailing whitespace
* code review feedback.
Makes AsyncMethodBuilderCore.TryFindContinuationTask check to
whether the target of a continuation is itself a task, as a fall-back
to checking to see if the continuation is a ContinuationWrapper
* Got rid of unnecessary null checks
Diffstat (limited to 'src')
-rw-r--r-- | src/System.Private.CoreLib/shared/System/Runtime/CompilerServices/AsyncMethodBuilder.cs | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/System.Private.CoreLib/shared/System/Runtime/CompilerServices/AsyncMethodBuilder.cs b/src/System.Private.CoreLib/shared/System/Runtime/CompilerServices/AsyncMethodBuilder.cs index 97c0535e3c..a2506481c2 100644 --- a/src/System.Private.CoreLib/shared/System/Runtime/CompilerServices/AsyncMethodBuilder.cs +++ b/src/System.Private.CoreLib/shared/System/Runtime/CompilerServices/AsyncMethodBuilder.cs @@ -1099,7 +1099,9 @@ namespace System.Runtime.CompilerServices } internal static Task? TryGetContinuationTask(Action continuation) => - (continuation?.Target as ContinuationWrapper)?._innerTask; + (continuation.Target is ContinuationWrapper wrapper) ? + wrapper._innerTask : // A wrapped continuation, created by an awaiter + continuation.Target as Task; // The continuation targets a task directly, such as with AsyncStateMachineBox /// <summary> /// Logically we pass just an Action (delegate) to a task for its action to 'ContinueWith' when it completes. |