From f3e9fb76fcf98e7da97687b64846878af8bfc0b7 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 7 Dec 2021 13:32:35 +0900 Subject: [PATCH 1/2] Add the ability to pass a `CancellationToken` through `DifficultyCalculator.CalculateAll` Was weirdly missing from this one method. --- osu.Game/Rulesets/Difficulty/DifficultyCalculator.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/osu.Game/Rulesets/Difficulty/DifficultyCalculator.cs b/osu.Game/Rulesets/Difficulty/DifficultyCalculator.cs index 01b4150030..6b6ea6fed5 100644 --- a/osu.Game/Rulesets/Difficulty/DifficultyCalculator.cs +++ b/osu.Game/Rulesets/Difficulty/DifficultyCalculator.cs @@ -120,14 +120,14 @@ namespace osu.Game.Rulesets.Difficulty /// Calculates the difficulty of the beatmap using all mod combinations applicable to the beatmap. /// /// A collection of structures describing the difficulty of the beatmap for each mod combination. - public IEnumerable CalculateAll() + public IEnumerable CalculateAll(CancellationToken cancellationToken = default) { foreach (var combination in CreateDifficultyAdjustmentModCombinations()) { if (combination is MultiMod multi) - yield return Calculate(multi.Mods); + yield return Calculate(multi.Mods, cancellationToken); else - yield return Calculate(combination.Yield()); + yield return Calculate(combination.Yield(), cancellationToken); } } From cfa712473d471862634941f559d5bbd614a15086 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 7 Dec 2021 13:33:41 +0900 Subject: [PATCH 2/2] Use default timeout in `GetPlayableBeatmap` when provided `CancellationToken` is `default` --- osu.Game/Rulesets/Difficulty/DifficultyCalculator.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/osu.Game/Rulesets/Difficulty/DifficultyCalculator.cs b/osu.Game/Rulesets/Difficulty/DifficultyCalculator.cs index 6b6ea6fed5..6b61dd3efb 100644 --- a/osu.Game/Rulesets/Difficulty/DifficultyCalculator.cs +++ b/osu.Game/Rulesets/Difficulty/DifficultyCalculator.cs @@ -145,7 +145,11 @@ namespace osu.Game.Rulesets.Difficulty { playableMods = mods.Select(m => m.DeepClone()).ToArray(); - Beatmap = beatmap.GetPlayableBeatmap(ruleset, playableMods, cancellationToken); + // Only pass through the cancellation token if it's non-default. + // This allows for the default timeout to be applied for playable beatmap construction. + Beatmap = cancellationToken == default + ? beatmap.GetPlayableBeatmap(ruleset, playableMods) + : beatmap.GetPlayableBeatmap(ruleset, playableMods, cancellationToken); var track = new TrackVirtual(10000); playableMods.OfType().ForEach(m => m.ApplyToTrack(track));