Re-query beatmap difficulty before computing

This commit is contained in:
smoogipoo 2020-08-28 22:08:28 +09:00
parent 2a1511f436
commit 43c61e5830
1 changed files with 8 additions and 2 deletions

View File

@ -89,8 +89,14 @@ public async Task<StarDifficulty> GetDifficultyAsync([NotNull] BeatmapInfo beatm
if (tryGetExisting(beatmapInfo, rulesetInfo, mods, out var existing, out var key))
return existing;
return await Task.Factory.StartNew(() => computeDifficulty(key, beatmapInfo, rulesetInfo), cancellationToken,
TaskCreationOptions.HideScheduler | TaskCreationOptions.RunContinuationsAsynchronously, updateScheduler);
return await Task.Factory.StartNew(() =>
{
// Computation may have finished in a previous task.
if (tryGetExisting(beatmapInfo, rulesetInfo, mods, out existing, out _))
return existing;
return computeDifficulty(key, beatmapInfo, rulesetInfo);
}, cancellationToken, TaskCreationOptions.HideScheduler | TaskCreationOptions.RunContinuationsAsynchronously, updateScheduler);
}
/// <summary>