Skip to content

Commit d75c448

Browse files
author
Lifeng Lu
committed
Fix typos & some nullable metadata in the code.
1 parent 9f6b366 commit d75c448

File tree

2 files changed

+10
-11
lines changed

2 files changed

+10
-11
lines changed

src/Microsoft.VisualStudio.Threading/JoinableTask.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -381,8 +381,8 @@ internal WeakReference<JoinableTask> WeakSelf
381381
}
382382

383383
/// <summary>
384-
/// Gets or sets potential unreacable dependent nodes.
385-
/// This is a special collection only used in sychronized task when there are other tasks which are marked to block it through ref-count code.
384+
/// Gets or sets potential unreachable dependent nodes.
385+
/// This is a special collection only used in synchronized task when there are other tasks which are marked to block it through ref-count code.
386386
/// However, it is possible the reference count is retained by loop-dependencies. This collection tracking those items,
387387
/// so the clean-up logic can run when it becomes necessary.
388388
/// </summary>
@@ -717,7 +717,7 @@ internal void Post(SendOrPostCallback d, object? state, bool mainThreadAffinitiz
717717
// because dependencies may change, and invalidate this work. However, we try to do this work in the background thread to make it less likely
718718
// doing the expensive work on the UI thread.
719719
if (JoinableTaskDependencyGraph.CleanUpPotentialUnreachableDependentItems(taskToNotify, out HashSet<IJoinableTaskDependent>? reachableNodes) &&
720-
!reachableNodes!.Contains(this))
720+
!reachableNodes.Contains(this))
721721
{
722722
continue;
723723
}
@@ -1128,7 +1128,7 @@ private bool TryDequeueSelfOrDependencies(bool onMainThread, ref HashSet<IJoinab
11281128
visited.Clear();
11291129
}
11301130

1131-
var foundWork = TryDequeueSelfOrDependencies(this, onMainThread, visited, out work);
1131+
bool foundWork = TryDequeueSelfOrDependencies(this, onMainThread, visited, out work);
11321132

11331133
HashSet<IJoinableTaskDependent>? visitedNodes = visited;
11341134
if (visitedNodes != null && this.PotentialUnreachableDependents != null)

src/Microsoft.VisualStudio.Threading/JoinableTaskDependencyGraph.cs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ internal static HashSet<JoinableTask> GetDependentTasksFromCandidates(IEnumerabl
226226
/// <param name="syncTask">A thread blocking sychornizing task.</param>
227227
/// <param name="allReachableNodes">Returns all reachable nodes in the connected dependency graph, if unreachable dependency is found.</param>
228228
/// <returns>True if it removes any unreachable items.</returns>
229-
internal static bool CleanUpPotentialUnreachableDependentItems(JoinableTask syncTask, [MaybeNullWhen(false)] out HashSet<IJoinableTaskDependent>? allReachableNodes)
229+
internal static bool CleanUpPotentialUnreachableDependentItems(JoinableTask syncTask, [NotNullWhen(true)] out HashSet<IJoinableTaskDependent>? allReachableNodes)
230230
{
231231
Requires.NotNull(syncTask, nameof(syncTask));
232232

@@ -254,11 +254,8 @@ internal static bool CleanUpPotentialUnreachableDependentItems(JoinableTask sync
254254
return true;
255255
}
256256
}
257-
else
258-
{
259-
allReachableNodes = null;
260-
}
261257

258+
allReachableNodes = null;
262259
return false;
263260
}
264261

@@ -607,7 +604,7 @@ internal bool HasMainThreadSynchronousTaskWaiting(IJoinableTaskDependent taskIte
607604
{
608605
// This might remove the current tracking item from the linked list, so we capture next node first.
609606
if (!CleanUpPotentialUnreachableDependentItems(existingTaskTracking.SynchronousTask, out HashSet<IJoinableTaskDependent>? allReachableNodes) ||
610-
allReachableNodes!.Contains(taskItem))
607+
allReachableNodes.Contains(taskItem))
611608
{
612609
// this task is still a dependenting task
613610
return true;
@@ -877,7 +874,9 @@ private static void RemoveDependingSynchronousTaskFrom(IReadOnlyList<IJoinableTa
877874
{
878875
if (force)
879876
{
880-
Assumes.True(reachableNodes!.Count == 0);
877+
Assumes.NotNull(reachableNodes);
878+
Assumes.True(reachableNodes.Count == 0);
879+
881880
RemoveUnreachableDependentItems(syncTask, remainNodes, reachableNodes);
882881

883882
syncTask.PotentialUnreachableDependents = null;

0 commit comments

Comments
 (0)