summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarek Safar <marek.safar@gmail.com>2019-01-18 12:00:02 +0100
committerStephen Toub <stoub@microsoft.com>2019-01-18 11:47:21 -0500
commit7fb4ac5629230302800991444f960feefc6da38c (patch)
treea408e07b93a3753da935dca99a1b6c07620352bd
parente3932d49956acae70e0732ff3cfde7d8dc51db67 (diff)
downloadcoreclr-7fb4ac5629230302800991444f960feefc6da38c.tar.gz
coreclr-7fb4ac5629230302800991444f960feefc6da38c.tar.bz2
coreclr-7fb4ac5629230302800991444f960feefc6da38c.zip
Fix defines in TaskAwaiter (dotnet/corert#6846)
Signed-off-by: dotnet-bot <dotnet-bot@microsoft.com>
-rw-r--r--src/System.Private.CoreLib/shared/System/Runtime/CompilerServices/TaskAwaiter.cs68
1 files changed, 34 insertions, 34 deletions
diff --git a/src/System.Private.CoreLib/shared/System/Runtime/CompilerServices/TaskAwaiter.cs b/src/System.Private.CoreLib/shared/System/Runtime/CompilerServices/TaskAwaiter.cs
index 86380f9e94..d73e21d242 100644
--- a/src/System.Private.CoreLib/shared/System/Runtime/CompilerServices/TaskAwaiter.cs
+++ b/src/System.Private.CoreLib/shared/System/Runtime/CompilerServices/TaskAwaiter.cs
@@ -41,7 +41,7 @@ using System.Diagnostics;
using System.Diagnostics.Tracing;
using System.Threading;
using System.Threading.Tasks;
-#if !CORECLR
+#if CORERT
using Internal.Threading.Tasks.Tracing;
#endif
@@ -210,10 +210,10 @@ namespace System.Runtime.CompilerServices
// If TaskWait* ETW events are enabled, trace a beginning event for this await
// and set up an ending event to be traced when the asynchronous await completes.
if (
-#if CORECLR
- TplEtwProvider.Log.IsEnabled() || Task.s_asyncDebuggingEnabled
-#else
+#if CORERT
TaskTrace.Enabled
+#else
+ TplEtwProvider.Log.IsEnabled() || Task.s_asyncDebuggingEnabled
#endif
)
{
@@ -235,10 +235,10 @@ namespace System.Runtime.CompilerServices
// If TaskWait* ETW events are enabled, trace a beginning event for this await
// and set up an ending event to be traced when the asynchronous await completes.
if (
-#if CORECLR
- TplEtwProvider.Log.IsEnabled() || Task.s_asyncDebuggingEnabled
-#else
+#if CORERT
TaskTrace.Enabled
+#else
+ TplEtwProvider.Log.IsEnabled() || Task.s_asyncDebuggingEnabled
#endif
)
{
@@ -260,7 +260,16 @@ namespace System.Runtime.CompilerServices
{
Debug.Assert(task != null, "Need a task to wait on");
Debug.Assert(continuation != null, "Need a continuation to invoke when the wait completes");
-#if CORECLR
+#if CORERT
+ Debug.Assert(TaskTrace.Enabled, "Should only be used when ETW tracing is enabled");
+
+ // ETW event for Task Wait Begin
+ var currentTaskAtBegin = Task.InternalCurrent;
+ TaskTrace.TaskWaitBegin_Asynchronous(
+ (currentTaskAtBegin != null ? currentTaskAtBegin.m_taskScheduler.Id : TaskScheduler.Default.Id),
+ (currentTaskAtBegin != null ? currentTaskAtBegin.Id : 0),
+ task.Id);
+#else
if (Task.s_asyncDebuggingEnabled)
{
Task.AddToActiveTasks(task);
@@ -281,15 +290,6 @@ namespace System.Runtime.CompilerServices
task.Id, TplEtwProvider.TaskWaitBehavior.Asynchronous,
(continuationTask != null ? continuationTask.Id : 0));
}
-#else
- Debug.Assert(TaskTrace.Enabled, "Should only be used when ETW tracing is enabled");
-
- // ETW event for Task Wait Begin
- var currentTaskAtBegin = Task.InternalCurrent;
- TaskTrace.TaskWaitBegin_Asynchronous(
- (currentTaskAtBegin != null ? currentTaskAtBegin.m_taskScheduler.Id : TaskScheduler.Default.Id),
- (currentTaskAtBegin != null ? currentTaskAtBegin.Id : 0),
- task.Id);
#endif
// Create a continuation action that outputs the end event and then invokes the user
@@ -297,7 +297,23 @@ namespace System.Runtime.CompilerServices
// is enabled, and in doing so it allows us to pass the awaited task's information into the end event
// in a purely pay-for-play manner (the alternatively would be to increase the size of TaskAwaiter
// just for this ETW purpose, not pay-for-play, since GetResult would need to know whether a real yield occurred).
-#if CORECLR
+#if CORERT
+ return () =>
+ {
+ // ETW event for Task Wait End.
+ if (TaskTrace.Enabled)
+ {
+ var currentTaskAtEnd = Task.InternalCurrent;
+ TaskTrace.TaskWaitEnd(
+ (currentTaskAtEnd != null ? currentTaskAtEnd.m_taskScheduler.Id : TaskScheduler.Default.Id),
+ (currentTaskAtEnd != null ? currentTaskAtEnd.Id : 0),
+ task.Id);
+ }
+
+ // Invoke the original continuation provided to OnCompleted.
+ continuation();
+ };
+#else
return AsyncMethodBuilderCore.CreateContinuationWrapper(continuation, (innerContinuation,innerTask) =>
{
if (Task.s_asyncDebuggingEnabled)
@@ -334,22 +350,6 @@ namespace System.Runtime.CompilerServices
EventSource.SetCurrentThreadActivityId(prevActivityId);
}
}, task);
-#else
- return () =>
- {
- // ETW event for Task Wait End.
- if (TaskTrace.Enabled)
- {
- var currentTaskAtEnd = Task.InternalCurrent;
- TaskTrace.TaskWaitEnd(
- (currentTaskAtEnd != null ? currentTaskAtEnd.m_taskScheduler.Id : TaskScheduler.Default.Id),
- (currentTaskAtEnd != null ? currentTaskAtEnd.Id : 0),
- task.Id);
- }
-
- // Invoke the original continuation provided to OnCompleted.
- continuation();
- };
#endif
}
}