Skip to content

Commit 26830dc

Browse files
author
Lifeng Lu
committed
Clean up synchronous task tracking from disconnected circular dependency islands.
1 parent 3b98e80 commit 26830dc

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/Microsoft.VisualStudio.Threading/JoinableTaskDependencyGraph.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ namespace Microsoft.VisualStudio.Threading
1616
/// </summary>
1717
internal static class JoinableTaskDependencyGraph
1818
{
19+
private static readonly HashSet<IJoinableTaskDependent> EmptySet = new HashSet<IJoinableTaskDependent>();
20+
1921
/// <summary>
2022
/// Gets a value indicating whether there is no child depenent item.
2123
/// This method is expected to be used with the JTF lock.
@@ -500,7 +502,13 @@ internal static void OnSynchronousTaskEndToBlockWaiting(JoinableTask syncTask)
500502
lock (syncTask.Factory.Context.SyncContextLock)
501503
{
502504
// Remove itself from the tracking list, after the task is completed.
503-
RemoveDependingSynchronousTask(syncTask, syncTask, true);
505+
RemoveDependingSynchronousTask(syncTask, syncTask, force: true);
506+
507+
if (syncTask.PotentialUnreachableDependents is object && syncTask.PotentialUnreachableDependents.Count > 0)
508+
{
509+
RemoveUnreachableDependentItems(syncTask, syncTask.PotentialUnreachableDependents, EmptySet);
510+
syncTask.PotentialUnreachableDependents = null;
511+
}
504512
}
505513
}
506514
}

0 commit comments

Comments
 (0)