Remove async calls from ScoreManager

This commit is contained in:
Dan Balasescu
2022-08-22 21:31:30 +09:00
parent c0b13c7e1f
commit 423f6f90f2
11 changed files with 62 additions and 187 deletions

View File

@ -8,10 +8,8 @@ using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Extensions;
using osu.Game.Beatmaps;
using osu.Game.Database;
using osu.Game.Extensions;
@ -150,17 +148,12 @@ namespace osu.Game.Screens.Select.Leaderboards
var req = new GetScoresRequest(fetchBeatmapInfo, fetchRuleset, Scope, requestMods);
req.Success += r =>
req.Success += r => Schedule(() =>
{
scoreManager.OrderByTotalScoreAsync(r.Scores.Select(s => s.ToScoreInfo(rulesets, fetchBeatmapInfo)).ToArray(), cancellationToken)
.ContinueWith(task => Schedule(() =>
{
if (cancellationToken.IsCancellationRequested)
return;
SetScores(task.GetResultSafely(), r.UserScore?.CreateScoreInfo(rulesets, fetchBeatmapInfo));
}), TaskContinuationOptions.OnlyOnRanToCompletion);
};
SetScores(
scoreManager.OrderByTotalScore(r.Scores.Select(s => s.ToScoreInfo(rulesets, fetchBeatmapInfo))),
r.UserScore?.CreateScoreInfo(rulesets, fetchBeatmapInfo));
});
return req;
}
@ -213,16 +206,9 @@ namespace osu.Game.Screens.Select.Leaderboards
scores = scores.Where(s => s.Mods.Any(m => selectedMods.Contains(m.Acronym)));
}
scores = scores.Detach();
scores = scoreManager.OrderByTotalScore(scores.Detach());
scoreManager.OrderByTotalScoreAsync(scores.ToArray(), cancellationToken)
.ContinueWith(ordered => Schedule(() =>
{
if (cancellationToken.IsCancellationRequested)
return;
SetScores(ordered.GetResultSafely());
}), TaskContinuationOptions.OnlyOnRanToCompletion);
Schedule(() => SetScores(scores));
}
}