mirror of
https://github.com/ppy/osu.git
synced 2025-01-28 02:43:19 +08:00
Fix potential blocking operation on OrderByTotalScoreAsync()
In reality this wouldn't be a long process, but the blocking is really noticeable if you add a Task.Delay(1000) in GetTotalScoreAsync().
This commit is contained in:
parent
a924b982eb
commit
b82ed3f167
@ -72,9 +72,12 @@ namespace osu.Game.Scoring
|
||||
}
|
||||
}
|
||||
|
||||
// We're calling .Result, but this should not be a blocking call due to the above GetDifficultyAsync() calls.
|
||||
return scores.OrderByDescending(s => GetTotalScoreAsync(s, cancellationToken: cancellationToken).Result)
|
||||
.ThenBy(s => s.OnlineScoreID)
|
||||
var totalScores = await Task.WhenAll(scores.Select(s => GetTotalScoreAsync(s, cancellationToken: cancellationToken))).ConfigureAwait(false);
|
||||
|
||||
return scores.Select((s, i) => (index: i, score: s))
|
||||
.OrderByDescending(key => totalScores[key.index])
|
||||
.ThenBy(key => key.score.OnlineScoreID)
|
||||
.Select(key => key.score)
|
||||
.ToArray();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user