mirror of
https://github.com/ppy/osu.git
synced 2025-01-30 08:52:58 +08:00
Merge pull request #8988 from peppy/dont-timeout-during-debug
Don't timeout on long beatmap load when debugging
This commit is contained in:
commit
adf9a90fc4
@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Diagnostics;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
@ -84,7 +85,7 @@ namespace osu.Game.Beatmaps
|
|||||||
|
|
||||||
public IBeatmap GetPlayableBeatmap(RulesetInfo ruleset, IReadOnlyList<Mod> mods = null, TimeSpan? timeout = null)
|
public IBeatmap GetPlayableBeatmap(RulesetInfo ruleset, IReadOnlyList<Mod> mods = null, TimeSpan? timeout = null)
|
||||||
{
|
{
|
||||||
using (var cancellationSource = new CancellationTokenSource(timeout ?? TimeSpan.FromSeconds(10)))
|
using (var cancellationSource = createCancellationTokenSource(timeout))
|
||||||
{
|
{
|
||||||
mods ??= Array.Empty<Mod>();
|
mods ??= Array.Empty<Mod>();
|
||||||
|
|
||||||
@ -181,6 +182,15 @@ namespace osu.Game.Beatmaps
|
|||||||
beatmapLoadTask = null;
|
beatmapLoadTask = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private CancellationTokenSource createCancellationTokenSource(TimeSpan? timeout)
|
||||||
|
{
|
||||||
|
if (Debugger.IsAttached)
|
||||||
|
// ignore timeout when debugger is attached (may be breakpointing / debugging).
|
||||||
|
return new CancellationTokenSource();
|
||||||
|
|
||||||
|
return new CancellationTokenSource(timeout ?? TimeSpan.FromSeconds(10));
|
||||||
|
}
|
||||||
|
|
||||||
private Task<IBeatmap> loadBeatmapAsync() => beatmapLoadTask ??= Task.Factory.StartNew(() =>
|
private Task<IBeatmap> loadBeatmapAsync() => beatmapLoadTask ??= Task.Factory.StartNew(() =>
|
||||||
{
|
{
|
||||||
// Todo: Handle cancellation during beatmap parsing
|
// Todo: Handle cancellation during beatmap parsing
|
||||||
|
Loading…
Reference in New Issue
Block a user