summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Kotas <jkotas@microsoft.com>2019-01-19 11:48:28 -0800
committerJan Kotas <jkotas@microsoft.com>2019-01-19 16:58:53 -0800
commit614966d1e179c32ce85df2791102847128390ca6 (patch)
tree69d990f9e7434de7121d4d0b774db8b3b2f0f61a
parent80416dc50cce9fae908e59e83a699af0c0ee9531 (diff)
downloadcoreclr-614966d1e179c32ce85df2791102847128390ca6.tar.gz
coreclr-614966d1e179c32ce85df2791102847128390ca6.tar.bz2
coreclr-614966d1e179c32ce85df2791102847128390ca6.zip
Fix CoreCLR build for changes in shared partition
-rw-r--r--src/System.Private.CoreLib/shared/System/Runtime/CompilerServices/AsyncMethodBuilder.cs1
-rw-r--r--src/System.Private.CoreLib/shared/System/Runtime/CompilerServices/TaskAwaiter.cs2
-rw-r--r--src/System.Private.CoreLib/src/System/Threading/Tasks/AsyncCausalityTracer.cs57
-rw-r--r--src/System.Private.CoreLib/src/System/Threading/Tasks/FutureFactory.cs55
-rw-r--r--src/System.Private.CoreLib/src/System/Threading/Tasks/Task.cs92
-rw-r--r--src/System.Private.CoreLib/src/System/Threading/Tasks/TaskContinuation.cs6
-rw-r--r--src/System.Private.CoreLib/src/System/Threading/Tasks/TaskFactory.cs36
7 files changed, 84 insertions, 165 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 f861998381..21f181031d 100644
--- a/src/System.Private.CoreLib/shared/System/Runtime/CompilerServices/AsyncMethodBuilder.cs
+++ b/src/System.Private.CoreLib/shared/System/Runtime/CompilerServices/AsyncMethodBuilder.cs
@@ -11,6 +11,7 @@
// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
using System.Diagnostics;
+using System.Diagnostics.Tracing;
using System.Reflection;
using System.Runtime.ExceptionServices;
#if FEATURE_COMINTEROP
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 d73e21d242..d6069ecfc0 100644
--- a/src/System.Private.CoreLib/shared/System/Runtime/CompilerServices/TaskAwaiter.cs
+++ b/src/System.Private.CoreLib/shared/System/Runtime/CompilerServices/TaskAwaiter.cs
@@ -318,7 +318,7 @@ namespace System.Runtime.CompilerServices
{
if (Task.s_asyncDebuggingEnabled)
{
- Task.RemoveFromActiveTasks(innerTask.Id);
+ Task.RemoveFromActiveTasks(innerTask);
}
TplEtwProvider innerEtwLog = TplEtwProvider.Log;
diff --git a/src/System.Private.CoreLib/src/System/Threading/Tasks/AsyncCausalityTracer.cs b/src/System.Private.CoreLib/src/System/Threading/Tasks/AsyncCausalityTracer.cs
index a06b3b8a07..cc8b34fbec 100644
--- a/src/System.Private.CoreLib/src/System/Threading/Tasks/AsyncCausalityTracer.cs
+++ b/src/System.Private.CoreLib/src/System/Threading/Tasks/AsyncCausalityTracer.cs
@@ -14,37 +14,6 @@ using WFD = Windows.Foundation.Diagnostics;
namespace System.Threading.Tasks
{
- internal enum CausalityTraceLevel
- {
- Required = WFD.CausalityTraceLevel.Required,
- Important = WFD.CausalityTraceLevel.Important,
- Verbose = WFD.CausalityTraceLevel.Verbose
- }
-
- internal enum AsyncCausalityStatus
- {
- Canceled = WFD.AsyncCausalityStatus.Canceled,
- Completed = WFD.AsyncCausalityStatus.Completed,
- Error = WFD.AsyncCausalityStatus.Error,
- Started = WFD.AsyncCausalityStatus.Started
- }
-
- internal enum CausalityRelation
- {
- AssignDelegate = WFD.CausalityRelation.AssignDelegate,
- Join = WFD.CausalityRelation.Join,
- Choice = WFD.CausalityRelation.Choice,
- Cancel = WFD.CausalityRelation.Cancel,
- Error = WFD.CausalityRelation.Error
- }
-
- internal enum CausalitySynchronousWork
- {
- CompletionNotification = WFD.CausalitySynchronousWork.CompletionNotification,
- ProgressNotification = WFD.CausalitySynchronousWork.ProgressNotification,
- Execution = WFD.CausalitySynchronousWork.Execution
- }
-
internal static class AsyncCausalityTracer
{
internal static void EnableToETW(bool enabled)
@@ -129,14 +98,15 @@ namespace System.Threading.Tasks
// The TraceXXX methods should be called only if LoggingOn property returned true
//
[MethodImplAttribute(MethodImplOptions.NoInlining)] // Tracking is slow path. Disable inlining for it.
- internal static void TraceOperationCreation(CausalityTraceLevel traceLevel, int taskId, string operationName, ulong relatedContext)
+ internal static void TraceOperationCreation(Task task, string operationName)
{
try
{
+ int taskId = task.Id;
if ((f_LoggingOn & Loggers.ETW) != 0)
- TplEtwProvider.Log.TraceOperationBegin(taskId, operationName, (long)relatedContext);
+ TplEtwProvider.Log.TraceOperationBegin(taskId, operationName, RelatedContext: 0);
if ((f_LoggingOn & Loggers.CausalityTracer) != 0)
- s_TracerFactory.TraceOperationCreation((WFD.CausalityTraceLevel)traceLevel, s_CausalitySource, s_PlatformId, GetOperationId((uint)taskId), operationName, relatedContext);
+ s_TracerFactory.TraceOperationCreation(WFD.CausalityTraceLevel.Required, s_CausalitySource, s_PlatformId, GetOperationId((uint)taskId), operationName, relatedContext: 0);
}
catch (Exception ex)
{
@@ -146,14 +116,15 @@ namespace System.Threading.Tasks
}
[MethodImplAttribute(MethodImplOptions.NoInlining)]
- internal static void TraceOperationCompletion(CausalityTraceLevel traceLevel, int taskId, AsyncCausalityStatus status)
+ internal static void TraceOperationCompletion(Task task, AsyncCausalityStatus status)
{
try
{
+ int taskId = task.Id;
if ((f_LoggingOn & Loggers.ETW) != 0)
TplEtwProvider.Log.TraceOperationEnd(taskId, status);
if ((f_LoggingOn & Loggers.CausalityTracer) != 0)
- s_TracerFactory.TraceOperationCompletion((WFD.CausalityTraceLevel)traceLevel, s_CausalitySource, s_PlatformId, GetOperationId((uint)taskId), (WFD.AsyncCausalityStatus)status);
+ s_TracerFactory.TraceOperationCompletion(WFD.CausalityTraceLevel.Required, s_CausalitySource, s_PlatformId, GetOperationId((uint)taskId), (WFD.AsyncCausalityStatus)status);
}
catch (Exception ex)
{
@@ -163,14 +134,15 @@ namespace System.Threading.Tasks
}
[MethodImplAttribute(MethodImplOptions.NoInlining)]
- internal static void TraceOperationRelation(CausalityTraceLevel traceLevel, int taskId, CausalityRelation relation)
+ internal static void TraceOperationRelation(Task task, CausalityRelation relation)
{
try
{
+ int taskId = task.Id;
if ((f_LoggingOn & Loggers.ETW) != 0)
TplEtwProvider.Log.TraceOperationRelation(taskId, relation);
if ((f_LoggingOn & Loggers.CausalityTracer) != 0)
- s_TracerFactory.TraceOperationRelation((WFD.CausalityTraceLevel)traceLevel, s_CausalitySource, s_PlatformId, GetOperationId((uint)taskId), (WFD.CausalityRelation)relation);
+ s_TracerFactory.TraceOperationRelation(WFD.CausalityTraceLevel.Important, s_CausalitySource, s_PlatformId, GetOperationId((uint)taskId), (WFD.CausalityRelation)relation);
}
catch (Exception ex)
{
@@ -180,14 +152,15 @@ namespace System.Threading.Tasks
}
[MethodImplAttribute(MethodImplOptions.NoInlining)]
- internal static void TraceSynchronousWorkStart(CausalityTraceLevel traceLevel, int taskId, CausalitySynchronousWork work)
+ internal static void TraceSynchronousWorkStart(Task task, CausalitySynchronousWork work)
{
try
{
+ int taskId = task.Id;
if ((f_LoggingOn & Loggers.ETW) != 0)
TplEtwProvider.Log.TraceSynchronousWorkBegin(taskId, work);
if ((f_LoggingOn & Loggers.CausalityTracer) != 0)
- s_TracerFactory.TraceSynchronousWorkStart((WFD.CausalityTraceLevel)traceLevel, s_CausalitySource, s_PlatformId, GetOperationId((uint)taskId), (WFD.CausalitySynchronousWork)work);
+ s_TracerFactory.TraceSynchronousWorkStart(WFD.CausalityTraceLevel.Required, s_CausalitySource, s_PlatformId, GetOperationId((uint)taskId), (WFD.CausalitySynchronousWork)work);
}
catch (Exception ex)
{
@@ -197,14 +170,14 @@ namespace System.Threading.Tasks
}
[MethodImplAttribute(MethodImplOptions.NoInlining)]
- internal static void TraceSynchronousWorkCompletion(CausalityTraceLevel traceLevel, CausalitySynchronousWork work)
+ internal static void TraceSynchronousWorkCompletion(CausalitySynchronousWork work)
{
try
{
if ((f_LoggingOn & Loggers.ETW) != 0)
TplEtwProvider.Log.TraceSynchronousWorkEnd(work);
if ((f_LoggingOn & Loggers.CausalityTracer) != 0)
- s_TracerFactory.TraceSynchronousWorkCompletion((WFD.CausalityTraceLevel)traceLevel, s_CausalitySource, (WFD.CausalitySynchronousWork)work);
+ s_TracerFactory.TraceSynchronousWorkCompletion(WFD.CausalityTraceLevel.Required, s_CausalitySource, (WFD.CausalitySynchronousWork)work);
}
catch (Exception ex)
{
diff --git a/src/System.Private.CoreLib/src/System/Threading/Tasks/FutureFactory.cs b/src/System.Private.CoreLib/src/System/Threading/Tasks/FutureFactory.cs
index 775c12f6b7..3ea1792d1b 100644
--- a/src/System.Private.CoreLib/src/System/Threading/Tasks/FutureFactory.cs
+++ b/src/System.Private.CoreLib/src/System/Threading/Tasks/FutureFactory.cs
@@ -552,12 +552,11 @@ namespace System.Threading.Tasks
else
{
if (AsyncCausalityTracer.LoggingOn)
- AsyncCausalityTracer.TraceOperationCompletion(CausalityTraceLevel.Required, promise.Id, AsyncCausalityStatus.Completed);
+ AsyncCausalityTracer.TraceOperationCompletion(promise, AsyncCausalityStatus.Completed);
if (Task.s_asyncDebuggingEnabled)
- {
- Task.RemoveFromActiveTasks(promise.Id);
- }
+ Task.RemoveFromActiveTasks(promise);
+
if (requiresSynchronization)
{
promise.TrySetResult(result);
@@ -675,12 +674,10 @@ namespace System.Threading.Tasks
Task<TResult> promise = new Task<TResult>((object)null, creationOptions);
if (AsyncCausalityTracer.LoggingOn)
- AsyncCausalityTracer.TraceOperationCreation(CausalityTraceLevel.Required, promise.Id, "TaskFactory.FromAsync", 0);
+ AsyncCausalityTracer.TraceOperationCreation(promise, "TaskFactory.FromAsync");
if (Task.s_asyncDebuggingEnabled)
- {
Task.AddToActiveTasks(promise);
- }
// Just specify this task as detached. No matter what happens, we want endMethod
// to be called -- even if the parent is canceled. So we don't want to flow
@@ -693,12 +690,10 @@ namespace System.Threading.Tasks
default, TaskCreationOptions.None, InternalTaskOptions.None, null);
if (AsyncCausalityTracer.LoggingOn)
- AsyncCausalityTracer.TraceOperationCreation(CausalityTraceLevel.Verbose, t.Id, "TaskFactory.FromAsync Callback", 0);
+ AsyncCausalityTracer.TraceOperationCreation(t, "TaskFactory.FromAsync Callback");
if (Task.s_asyncDebuggingEnabled)
- {
Task.AddToActiveTasks(t);
- }
if (asyncResult.IsCompleted)
{
@@ -794,12 +789,10 @@ namespace System.Threading.Tasks
Task<TResult> promise = new Task<TResult>(state, creationOptions);
if (AsyncCausalityTracer.LoggingOn)
- AsyncCausalityTracer.TraceOperationCreation(CausalityTraceLevel.Required, promise.Id, "TaskFactory.FromAsync: " + beginMethod.Method.Name, 0);
+ AsyncCausalityTracer.TraceOperationCreation(promise, "TaskFactory.FromAsync: " + beginMethod.Method.Name);
if (Task.s_asyncDebuggingEnabled)
- {
Task.AddToActiveTasks(promise);
- }
try
{
@@ -819,12 +812,10 @@ namespace System.Threading.Tasks
catch
{
if (AsyncCausalityTracer.LoggingOn)
- AsyncCausalityTracer.TraceOperationCompletion(CausalityTraceLevel.Required, promise.Id, AsyncCausalityStatus.Error);
+ AsyncCausalityTracer.TraceOperationCompletion(promise, AsyncCausalityStatus.Error);
if (Task.s_asyncDebuggingEnabled)
- {
- Task.RemoveFromActiveTasks(promise.Id);
- }
+ Task.RemoveFromActiveTasks(promise);
// Make sure we don't leave promise "dangling".
promise.TrySetResult(default);
@@ -916,12 +907,10 @@ namespace System.Threading.Tasks
Task<TResult> promise = new Task<TResult>(state, creationOptions);
if (AsyncCausalityTracer.LoggingOn)
- AsyncCausalityTracer.TraceOperationCreation(CausalityTraceLevel.Required, promise.Id, "TaskFactory.FromAsync: " + beginMethod.Method.Name, 0);
+ AsyncCausalityTracer.TraceOperationCreation(promise, "TaskFactory.FromAsync: " + beginMethod.Method.Name);
if (Task.s_asyncDebuggingEnabled)
- {
Task.AddToActiveTasks(promise);
- }
try
{
@@ -940,12 +929,10 @@ namespace System.Threading.Tasks
catch
{
if (AsyncCausalityTracer.LoggingOn)
- AsyncCausalityTracer.TraceOperationCompletion(CausalityTraceLevel.Required, promise.Id, AsyncCausalityStatus.Error);
+ AsyncCausalityTracer.TraceOperationCompletion(promise, AsyncCausalityStatus.Error);
if (Task.s_asyncDebuggingEnabled)
- {
- Task.RemoveFromActiveTasks(promise.Id);
- }
+ Task.RemoveFromActiveTasks(promise);
// Make sure we don't leave promise "dangling".
promise.TrySetResult(default);
@@ -1045,12 +1032,10 @@ namespace System.Threading.Tasks
Task<TResult> promise = new Task<TResult>(state, creationOptions);
if (AsyncCausalityTracer.LoggingOn)
- AsyncCausalityTracer.TraceOperationCreation(CausalityTraceLevel.Required, promise.Id, "TaskFactory.FromAsync: " + beginMethod.Method.Name, 0);
+ AsyncCausalityTracer.TraceOperationCreation(promise, "TaskFactory.FromAsync: " + beginMethod.Method.Name);
if (Task.s_asyncDebuggingEnabled)
- {
Task.AddToActiveTasks(promise);
- }
try
{
@@ -1069,12 +1054,10 @@ namespace System.Threading.Tasks
catch
{
if (AsyncCausalityTracer.LoggingOn)
- AsyncCausalityTracer.TraceOperationCompletion(CausalityTraceLevel.Required, promise.Id, AsyncCausalityStatus.Error);
+ AsyncCausalityTracer.TraceOperationCompletion(promise, AsyncCausalityStatus.Error);
if (Task.s_asyncDebuggingEnabled)
- {
- Task.RemoveFromActiveTasks(promise.Id);
- }
+ Task.RemoveFromActiveTasks(promise);
// Make sure we don't leave promise "dangling".
promise.TrySetResult(default);
@@ -1182,12 +1165,10 @@ namespace System.Threading.Tasks
Task<TResult> promise = new Task<TResult>(state, creationOptions);
if (AsyncCausalityTracer.LoggingOn)
- AsyncCausalityTracer.TraceOperationCreation(CausalityTraceLevel.Required, promise.Id, "TaskFactory.FromAsync: " + beginMethod.Method.Name, 0);
+ AsyncCausalityTracer.TraceOperationCreation(promise, "TaskFactory.FromAsync: " + beginMethod.Method.Name);
if (Task.s_asyncDebuggingEnabled)
- {
Task.AddToActiveTasks(promise);
- }
try
{
@@ -1206,12 +1187,10 @@ namespace System.Threading.Tasks
catch
{
if (AsyncCausalityTracer.LoggingOn)
- AsyncCausalityTracer.TraceOperationCompletion(CausalityTraceLevel.Required, promise.Id, AsyncCausalityStatus.Error);
+ AsyncCausalityTracer.TraceOperationCompletion(promise, AsyncCausalityStatus.Error);
if (Task.s_asyncDebuggingEnabled)
- {
- Task.RemoveFromActiveTasks(promise.Id);
- }
+ Task.RemoveFromActiveTasks(promise);
// Make sure we don't leave the promise "dangling".
promise.TrySetResult(default);
diff --git a/src/System.Private.CoreLib/src/System/Threading/Tasks/Task.cs b/src/System.Private.CoreLib/src/System/Threading/Tasks/Task.cs
index 2f40654cdf..1736d6aede 100644
--- a/src/System.Private.CoreLib/src/System/Threading/Tasks/Task.cs
+++ b/src/System.Private.CoreLib/src/System/Threading/Tasks/Task.cs
@@ -214,16 +214,19 @@ namespace System.Threading.Tasks
internal static bool AddToActiveTasks(Task task)
{
Debug.Assert(task != null, "Null Task objects can't be added to the ActiveTasks collection");
+
+ int taskId = task.Id;
lock (s_activeTasksLock)
{
- s_currentActiveTasks[task.Id] = task;
+ s_currentActiveTasks[taskId] = task;
}
//always return true to keep signature as bool for backwards compatibility
return true;
}
- internal static void RemoveFromActiveTasks(int taskId)
+ internal static void RemoveFromActiveTasks(Task task)
{
+ int taskId = task.Id;
lock (s_activeTasksLock)
{
s_currentActiveTasks.Remove(taskId);
@@ -1744,14 +1747,12 @@ namespace System.Threading.Tasks
}
if (s_asyncDebuggingEnabled)
- {
AddToActiveTasks(this);
- }
if (AsyncCausalityTracer.LoggingOn && (Options & (TaskCreationOptions)InternalTaskOptions.ContinuationTask) == 0)
{
//For all other task than TaskContinuations we want to log. TaskContinuations log in their constructor
- AsyncCausalityTracer.TraceOperationCreation(CausalityTraceLevel.Required, this.Id, "Task: " + m_action.Method.Name, 0);
+ AsyncCausalityTracer.TraceOperationCreation(this, "Task: " + m_action.Method.Name);
}
@@ -2108,12 +2109,10 @@ namespace System.Threading.Tasks
{
completionState = TASK_STATE_FAULTED;
if (AsyncCausalityTracer.LoggingOn)
- AsyncCausalityTracer.TraceOperationCompletion(CausalityTraceLevel.Required, this.Id, AsyncCausalityStatus.Error);
+ AsyncCausalityTracer.TraceOperationCompletion(this, AsyncCausalityStatus.Error);
if (Task.s_asyncDebuggingEnabled)
- {
- RemoveFromActiveTasks(this.Id);
- }
+ RemoveFromActiveTasks(this);
}
else if (IsCancellationRequested && IsCancellationAcknowledged)
{
@@ -2126,23 +2125,19 @@ namespace System.Threading.Tasks
completionState = TASK_STATE_CANCELED;
if (AsyncCausalityTracer.LoggingOn)
- AsyncCausalityTracer.TraceOperationCompletion(CausalityTraceLevel.Required, this.Id, AsyncCausalityStatus.Canceled);
+ AsyncCausalityTracer.TraceOperationCompletion(this, AsyncCausalityStatus.Canceled);
if (Task.s_asyncDebuggingEnabled)
- {
- RemoveFromActiveTasks(this.Id);
- }
+ RemoveFromActiveTasks(this);
}
else
{
completionState = TASK_STATE_RAN_TO_COMPLETION;
if (AsyncCausalityTracer.LoggingOn)
- AsyncCausalityTracer.TraceOperationCompletion(CausalityTraceLevel.Required, this.Id, AsyncCausalityStatus.Completed);
+ AsyncCausalityTracer.TraceOperationCompletion(this, AsyncCausalityStatus.Completed);
if (Task.s_asyncDebuggingEnabled)
- {
- RemoveFromActiveTasks(this.Id);
- }
+ RemoveFromActiveTasks(this);
}
// Use Interlocked.Exchange() to effect a memory fence, preventing
@@ -2418,7 +2413,7 @@ namespace System.Threading.Tasks
bool loggingOn = AsyncCausalityTracer.LoggingOn;
if (loggingOn)
- AsyncCausalityTracer.TraceSynchronousWorkStart(CausalityTraceLevel.Required, this.Id, CausalitySynchronousWork.Execution);
+ AsyncCausalityTracer.TraceSynchronousWorkStart(this, CausalitySynchronousWork.Execution);
try
{
@@ -2461,7 +2456,7 @@ namespace System.Threading.Tasks
}
if (loggingOn)
- AsyncCausalityTracer.TraceSynchronousWorkCompletion(CausalityTraceLevel.Required, CausalitySynchronousWork.Execution);
+ AsyncCausalityTracer.TraceSynchronousWorkCompletion(CausalitySynchronousWork.Execution);
Finish(true);
}
@@ -3210,12 +3205,10 @@ namespace System.Threading.Tasks
}
if (AsyncCausalityTracer.LoggingOn)
- AsyncCausalityTracer.TraceOperationCompletion(CausalityTraceLevel.Required, this.Id, AsyncCausalityStatus.Canceled);
+ AsyncCausalityTracer.TraceOperationCompletion(this, AsyncCausalityStatus.Canceled);
if (Task.s_asyncDebuggingEnabled)
- {
- RemoveFromActiveTasks(this.Id);
- }
+ RemoveFromActiveTasks(this);
// Notify parents, fire continuations, other cleanup.
FinishStageThree();
@@ -3268,7 +3261,7 @@ namespace System.Threading.Tasks
}
if (AsyncCausalityTracer.LoggingOn)
- AsyncCausalityTracer.TraceSynchronousWorkStart(CausalityTraceLevel.Required, this.Id, CausalitySynchronousWork.CompletionNotification);
+ AsyncCausalityTracer.TraceSynchronousWorkStart(this, CausalitySynchronousWork.CompletionNotification);
// Skip synchronous execution of continuations if this task's thread was aborted
bool canInlineContinuations = !(((m_stateFlags & TASK_STATE_THREAD_WAS_ABORTED) != 0) ||
@@ -3388,7 +3381,7 @@ namespace System.Threading.Tasks
private void LogFinishCompletionNotification()
{
if (AsyncCausalityTracer.LoggingOn)
- AsyncCausalityTracer.TraceSynchronousWorkCompletion(CausalityTraceLevel.Required, CausalitySynchronousWork.CompletionNotification);
+ AsyncCausalityTracer.TraceSynchronousWorkCompletion(CausalitySynchronousWork.CompletionNotification);
}
#region Continuation methods
@@ -5445,12 +5438,10 @@ namespace System.Threading.Tasks
{
this.Token = token;
if (AsyncCausalityTracer.LoggingOn)
- AsyncCausalityTracer.TraceOperationCreation(CausalityTraceLevel.Required, this.Id, "Task.Delay", 0);
+ AsyncCausalityTracer.TraceOperationCreation(this, "Task.Delay");
if (Task.s_asyncDebuggingEnabled)
- {
AddToActiveTasks(this);
- }
}
internal readonly CancellationToken Token;
@@ -5469,12 +5460,11 @@ namespace System.Threading.Tasks
else
{
if (AsyncCausalityTracer.LoggingOn)
- AsyncCausalityTracer.TraceOperationCompletion(CausalityTraceLevel.Required, this.Id, AsyncCausalityStatus.Completed);
+ AsyncCausalityTracer.TraceOperationCompletion(this, AsyncCausalityStatus.Completed);
if (Task.s_asyncDebuggingEnabled)
- {
- RemoveFromActiveTasks(this.Id);
- }
+ RemoveFromActiveTasks(this);
+
setSucceeded = TrySetResult(default);
}
@@ -5636,12 +5626,10 @@ namespace System.Threading.Tasks
Debug.Assert(tasks.Length > 0, "Expected a non-zero length task array");
if (AsyncCausalityTracer.LoggingOn)
- AsyncCausalityTracer.TraceOperationCreation(CausalityTraceLevel.Required, this.Id, "Task.WhenAll", 0);
+ AsyncCausalityTracer.TraceOperationCreation(this, "Task.WhenAll");
if (s_asyncDebuggingEnabled)
- {
AddToActiveTasks(this);
- }
m_tasks = tasks;
m_count = tasks.Length;
@@ -5656,7 +5644,7 @@ namespace System.Threading.Tasks
public void Invoke(Task completedTask)
{
if (AsyncCausalityTracer.LoggingOn)
- AsyncCausalityTracer.TraceOperationRelation(CausalityTraceLevel.Important, this.Id, CausalityRelation.Join);
+ AsyncCausalityTracer.TraceOperationRelation(this, CausalityRelation.Join);
// Decrement the count, and only continue to complete the promise if we're the last one.
if (Interlocked.Decrement(ref m_count) == 0)
@@ -5705,12 +5693,11 @@ namespace System.Threading.Tasks
else
{
if (AsyncCausalityTracer.LoggingOn)
- AsyncCausalityTracer.TraceOperationCompletion(CausalityTraceLevel.Required, this.Id, AsyncCausalityStatus.Completed);
+ AsyncCausalityTracer.TraceOperationCompletion(this, AsyncCausalityStatus.Completed);
if (Task.s_asyncDebuggingEnabled)
- {
- RemoveFromActiveTasks(this.Id);
- }
+ RemoveFromActiveTasks(this);
+
TrySetResult(default);
}
}
@@ -5882,12 +5869,10 @@ namespace System.Threading.Tasks
m_count = tasks.Length;
if (AsyncCausalityTracer.LoggingOn)
- AsyncCausalityTracer.TraceOperationCreation(CausalityTraceLevel.Required, this.Id, "Task.WhenAll", 0);
+ AsyncCausalityTracer.TraceOperationCreation(this, "Task.WhenAll");
if (s_asyncDebuggingEnabled)
- {
AddToActiveTasks(this);
- }
foreach (var task in tasks)
{
@@ -5899,7 +5884,7 @@ namespace System.Threading.Tasks
public void Invoke(Task ignored)
{
if (AsyncCausalityTracer.LoggingOn)
- AsyncCausalityTracer.TraceOperationRelation(CausalityTraceLevel.Important, this.Id, CausalityRelation.Join);
+ AsyncCausalityTracer.TraceOperationRelation(this, CausalityRelation.Join);
// Decrement the count, and only continue to complete the promise if we're the last one.
if (Interlocked.Decrement(ref m_count) == 0)
@@ -5954,12 +5939,11 @@ namespace System.Threading.Tasks
else
{
if (AsyncCausalityTracer.LoggingOn)
- AsyncCausalityTracer.TraceOperationCompletion(CausalityTraceLevel.Required, this.Id, AsyncCausalityStatus.Completed);
+ AsyncCausalityTracer.TraceOperationCompletion(this, AsyncCausalityStatus.Completed);
if (Task.s_asyncDebuggingEnabled)
- {
- RemoveFromActiveTasks(this.Id);
- }
+ RemoveFromActiveTasks(this);
+
TrySetResult(results);
}
}
@@ -6516,12 +6500,10 @@ namespace System.Threading.Tasks
_state = STATE_WAITING_ON_OUTER_TASK;
if (AsyncCausalityTracer.LoggingOn)
- AsyncCausalityTracer.TraceOperationCreation(CausalityTraceLevel.Required, this.Id, "Task.Unwrap", 0);
+ AsyncCausalityTracer.TraceOperationCreation(this, "Task.Unwrap");
if (Task.s_asyncDebuggingEnabled)
- {
AddToActiveTasks(this);
- }
// Link ourselves to the outer task.
// If the outer task has already completed, take the fast path
@@ -6629,7 +6611,7 @@ namespace System.Threading.Tasks
Debug.Assert(task != null && task.IsCompleted, "TrySetFromTask: Expected task to have completed.");
if (AsyncCausalityTracer.LoggingOn)
- AsyncCausalityTracer.TraceOperationRelation(CausalityTraceLevel.Important, this.Id, CausalityRelation.Join);
+ AsyncCausalityTracer.TraceOperationRelation(this, CausalityRelation.Join);
bool result = false;
switch (task.Status)
@@ -6658,12 +6640,10 @@ namespace System.Threading.Tasks
var taskTResult = task as Task<TResult>;
if (AsyncCausalityTracer.LoggingOn)
- AsyncCausalityTracer.TraceOperationCompletion(CausalityTraceLevel.Required, this.Id, AsyncCausalityStatus.Completed);
+ AsyncCausalityTracer.TraceOperationCompletion(this, AsyncCausalityStatus.Completed);
if (Task.s_asyncDebuggingEnabled)
- {
- RemoveFromActiveTasks(this.Id);
- }
+ RemoveFromActiveTasks(this);
result = TrySetResult(taskTResult != null ? taskTResult.Result : default);
break;
diff --git a/src/System.Private.CoreLib/src/System/Threading/Tasks/TaskContinuation.cs b/src/System.Private.CoreLib/src/System/Threading/Tasks/TaskContinuation.cs
index e7a7060e49..960d9c8485 100644
--- a/src/System.Private.CoreLib/src/System/Threading/Tasks/TaskContinuation.cs
+++ b/src/System.Private.CoreLib/src/System/Threading/Tasks/TaskContinuation.cs
@@ -295,12 +295,10 @@ namespace System.Threading.Tasks
m_options = options;
m_taskScheduler = scheduler;
if (AsyncCausalityTracer.LoggingOn)
- AsyncCausalityTracer.TraceOperationCreation(CausalityTraceLevel.Required, m_task.Id, "Task.ContinueWith: " + task.m_action.Method.Name, 0);
+ AsyncCausalityTracer.TraceOperationCreation(m_task, "Task.ContinueWith: " + task.m_action.Method.Name);
if (Task.s_asyncDebuggingEnabled)
- {
Task.AddToActiveTasks(m_task);
- }
}
/// <summary>Invokes the continuation for the target completion task.</summary>
@@ -331,7 +329,7 @@ namespace System.Threading.Tasks
if (!continuationTask.IsCanceled && AsyncCausalityTracer.LoggingOn)
{
// Log now that we are sure that this continuation is being ran
- AsyncCausalityTracer.TraceOperationRelation(CausalityTraceLevel.Important, continuationTask.Id, CausalityRelation.AssignDelegate);
+ AsyncCausalityTracer.TraceOperationRelation(continuationTask, CausalityRelation.AssignDelegate);
}
continuationTask.m_taskScheduler = m_taskScheduler;
diff --git a/src/System.Private.CoreLib/src/System/Threading/Tasks/TaskFactory.cs b/src/System.Private.CoreLib/src/System/Threading/Tasks/TaskFactory.cs
index 5ce41461da..c7281f503f 100644
--- a/src/System.Private.CoreLib/src/System/Threading/Tasks/TaskFactory.cs
+++ b/src/System.Private.CoreLib/src/System/Threading/Tasks/TaskFactory.cs
@@ -1562,29 +1562,25 @@ namespace System.Threading.Tasks
_count = tasksCopy.Length;
if (AsyncCausalityTracer.LoggingOn)
- AsyncCausalityTracer.TraceOperationCreation(CausalityTraceLevel.Required, this.Id, "TaskFactory.ContinueWhenAll", 0);
+ AsyncCausalityTracer.TraceOperationCreation(this, "TaskFactory.ContinueWhenAll");
if (Task.s_asyncDebuggingEnabled)
- {
AddToActiveTasks(this);
- }
}
public void Invoke(Task completingTask)
{
if (AsyncCausalityTracer.LoggingOn)
- AsyncCausalityTracer.TraceOperationRelation(CausalityTraceLevel.Important, this.Id, CausalityRelation.Join);
+ AsyncCausalityTracer.TraceOperationRelation(this, CausalityRelation.Join);
if (completingTask.IsWaitNotificationEnabled) this.SetNotificationForWaitCompletion(enabled: true);
if (Interlocked.Decrement(ref _count) == 0)
{
if (AsyncCausalityTracer.LoggingOn)
- AsyncCausalityTracer.TraceOperationCompletion(CausalityTraceLevel.Required, this.Id, AsyncCausalityStatus.Completed);
+ AsyncCausalityTracer.TraceOperationCompletion(this, AsyncCausalityStatus.Completed);
if (Task.s_asyncDebuggingEnabled)
- {
- RemoveFromActiveTasks(this.Id);
- }
+ RemoveFromActiveTasks(this);
TrySetResult(_tasks);
}
@@ -1642,29 +1638,25 @@ namespace System.Threading.Tasks
_count = tasksCopy.Length;
if (AsyncCausalityTracer.LoggingOn)
- AsyncCausalityTracer.TraceOperationCreation(CausalityTraceLevel.Required, this.Id, "TaskFactory.ContinueWhenAll<>", 0);
+ AsyncCausalityTracer.TraceOperationCreation(this, "TaskFactory.ContinueWhenAll<>");
if (Task.s_asyncDebuggingEnabled)
- {
AddToActiveTasks(this);
- }
}
public void Invoke(Task completingTask)
{
if (AsyncCausalityTracer.LoggingOn)
- AsyncCausalityTracer.TraceOperationRelation(CausalityTraceLevel.Important, this.Id, CausalityRelation.Join);
+ AsyncCausalityTracer.TraceOperationRelation(this, CausalityRelation.Join);
if (completingTask.IsWaitNotificationEnabled) this.SetNotificationForWaitCompletion(enabled: true);
if (Interlocked.Decrement(ref _count) == 0)
{
if (AsyncCausalityTracer.LoggingOn)
- AsyncCausalityTracer.TraceOperationCompletion(CausalityTraceLevel.Required, this.Id, AsyncCausalityStatus.Completed);
+ AsyncCausalityTracer.TraceOperationCompletion(this, AsyncCausalityStatus.Completed);
if (Task.s_asyncDebuggingEnabled)
- {
- RemoveFromActiveTasks(this.Id);
- }
+ RemoveFromActiveTasks(this);
TrySetResult(_tasks);
}
@@ -2298,12 +2290,10 @@ namespace System.Threading.Tasks
_tasks = tasks;
if (AsyncCausalityTracer.LoggingOn)
- AsyncCausalityTracer.TraceOperationCreation(CausalityTraceLevel.Required, this.Id, "TaskFactory.ContinueWhenAny", 0);
+ AsyncCausalityTracer.TraceOperationCreation(this, "TaskFactory.ContinueWhenAny");
if (Task.s_asyncDebuggingEnabled)
- {
AddToActiveTasks(this);
- }
}
public void Invoke(Task completingTask)
@@ -2313,14 +2303,12 @@ namespace System.Threading.Tasks
{
if (AsyncCausalityTracer.LoggingOn)
{
- AsyncCausalityTracer.TraceOperationRelation(CausalityTraceLevel.Important, this.Id, CausalityRelation.Choice);
- AsyncCausalityTracer.TraceOperationCompletion(CausalityTraceLevel.Required, this.Id, AsyncCausalityStatus.Completed);
+ AsyncCausalityTracer.TraceOperationRelation(this, CausalityRelation.Choice);
+ AsyncCausalityTracer.TraceOperationCompletion(this, AsyncCausalityStatus.Completed);
}
if (Task.s_asyncDebuggingEnabled)
- {
- RemoveFromActiveTasks(this.Id);
- }
+ RemoveFromActiveTasks(this);
bool success = TrySetResult(completingTask);
Debug.Assert(success, "Only one task should have gotten to this point, and thus this must be successful.");