Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Slightly simplify execution strategy logic #20754

Merged
merged 1 commit into from
Apr 26, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 7 additions & 9 deletions src/EFCore/Storage/ExecutionStrategy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,6 @@ private TResult ExecuteImplementation<TState, TResult>(
{
while (true)
{
TimeSpan? delay;
try
{
Suspended = true;
Expand Down Expand Up @@ -194,7 +193,7 @@ private TResult ExecuteImplementation<TState, TResult>(

ExceptionsEncountered.Add(ex);

delay = GetNextDelay(ex);
var delay = GetNextDelay(ex);
if (delay == null)
{
throw new RetryLimitExceededException(CoreStrings.RetryLimitExceeded(MaxRetryCount, GetType().Name), ex);
Expand All @@ -203,10 +202,10 @@ private TResult ExecuteImplementation<TState, TResult>(
Dependencies.Logger.ExecutionStrategyRetrying(ExceptionsEncountered, delay.Value, async: true);

OnRetry();
}

using var waitEvent = new ManualResetEventSlim(false);
waitEvent.WaitHandle.WaitOne(delay.Value);
using var waitEvent = new ManualResetEventSlim(false);
waitEvent.WaitHandle.WaitOne(delay.Value);
}
}
}

Expand Down Expand Up @@ -259,7 +258,6 @@ private async Task<TResult> ExecuteImplementationAsync<TState, TResult>(
{
cancellationToken.ThrowIfCancellationRequested();

TimeSpan? delay;
try
{
Suspended = true;
Expand Down Expand Up @@ -287,7 +285,7 @@ private async Task<TResult> ExecuteImplementationAsync<TState, TResult>(

ExceptionsEncountered.Add(ex);

delay = GetNextDelay(ex);
var delay = GetNextDelay(ex);
if (delay == null)
{
throw new RetryLimitExceededException(CoreStrings.RetryLimitExceeded(MaxRetryCount, GetType().Name), ex);
Expand All @@ -296,9 +294,9 @@ private async Task<TResult> ExecuteImplementationAsync<TState, TResult>(
Dependencies.Logger.ExecutionStrategyRetrying(ExceptionsEncountered, delay.Value, async: true);

OnRetry();
}

await Task.Delay(delay.Value, cancellationToken);
await Task.Delay(delay.Value, cancellationToken);
}
}
}

Expand Down