Skip to content

Commit

Permalink
Move to caller
Browse files Browse the repository at this point in the history
  • Loading branch information
CyrusNajmabadi committed May 31, 2024
1 parent 9d971ac commit 338c27d
Showing 1 changed file with 9 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ internal partial class NavigationBarController
using var linkedTokenSource = CancellationTokenSource.CreateLinkedTokenSource(lastNonFrozenComputationToken, cancellationToken);
try
{
return await ComputeModelAndSelectItemAsync(frozenPartialSemantics, linkedTokenSource.Token).ConfigureAwait(false);
return await ComputeModelAndSelectItemAsync(frozenPartialSemantics: false, linkedTokenSource.Token).ConfigureAwait(false);
}
catch (OperationCanceledException ex) when (ExceptionUtilities.IsCurrentOperationBeingCancelled(ex, linkedTokenSource.Token))
{
Expand All @@ -58,7 +58,14 @@ internal partial class NavigationBarController
else
{
// Normal request to either compute nav-bar items using frozen partial semantics.
return await ComputeModelAndSelectItemAsync(frozenPartialSemantics, cancellationToken).ConfigureAwait(false);
var model = await ComputeModelAndSelectItemAsync(frozenPartialSemantics: true, cancellationToken).ConfigureAwait(false);

// After that completes, enqueue work to compute *without* frozen partial snapshots so we move to accurate
// results shortly. Create and pass along a new cancellation token for this expensive work so that it can be
// canceled by future lightweight work.
_computeModelQueue.AddWork(new NavigationBarQueueItem(FrozenPartialSemantics: false, _nonFrozenComputationCancellationSeries.CreateNext(default)));

return model;
}
}

Expand All @@ -85,12 +92,6 @@ internal partial class NavigationBarController

var model = await ComputeModelAsync().ConfigureAwait(false);

// If we were computing with frozen partial semantics here, enqueue work to compute *without* frozen
// partial snapshots so we move to accurate results shortly. Create and pass along a new cancellation
// token for this expensive work so that it can be canceled by future lightweight work.
if (frozenPartialSemantics)
_computeModelQueue.AddWork(new NavigationBarQueueItem(FrozenPartialSemantics: false, _nonFrozenComputationCancellationSeries.CreateNext(default)));

// Now, enqueue work to select the right item in this new model. Note: we don't want to cancel existing items in
// the queue as it may be the case that the user moved between us capturing the initial caret point and now, and
// we'd want the selection work we enqueued for that to take precedence over us.
Expand Down

0 comments on commit 338c27d

Please sign in to comment.