Fix entire TPL thread potentially being consumed during gameplay

This commit is contained in:
Dan Balasescu
2022-09-09 09:59:39 +09:00
parent 731d3f3b63
commit 3b932b46ca

View File

@ -5,7 +5,6 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.Linq; using System.Linq;
using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using Newtonsoft.Json; using Newtonsoft.Json;
using osu.Framework.Allocation; using osu.Framework.Allocation;
@ -50,7 +49,7 @@ namespace osu.Game
{ {
Logger.Log("Beginning background beatmap processing.."); Logger.Log("Beginning background beatmap processing..");
checkForOutdatedStarRatings(); checkForOutdatedStarRatings();
processBeatmapSetsWithMissingMetrics(); await processBeatmapSetsWithMissingMetrics();
await processScoresWithMissingStatistics(); await processScoresWithMissingStatistics();
}).ContinueWith(t => }).ContinueWith(t =>
{ {
@ -100,7 +99,7 @@ namespace osu.Game
} }
} }
private void processBeatmapSetsWithMissingMetrics() private async Task processBeatmapSetsWithMissingMetrics()
{ {
HashSet<Guid> beatmapSetIds = new HashSet<Guid>(); HashSet<Guid> beatmapSetIds = new HashSet<Guid>();
@ -124,7 +123,7 @@ namespace osu.Game
while (localUserPlayInfo?.IsPlaying.Value == true) while (localUserPlayInfo?.IsPlaying.Value == true)
{ {
Logger.Log("Background processing sleeping due to active gameplay..."); Logger.Log("Background processing sleeping due to active gameplay...");
Thread.Sleep(TimeToSleepDuringGameplay); await Task.Delay(TimeToSleepDuringGameplay);
} }
realmAccess.Run(r => realmAccess.Run(r =>
@ -169,7 +168,7 @@ namespace osu.Game
while (localUserPlayInfo?.IsPlaying.Value == true) while (localUserPlayInfo?.IsPlaying.Value == true)
{ {
Logger.Log("Background processing sleeping due to active gameplay..."); Logger.Log("Background processing sleeping due to active gameplay...");
Thread.Sleep(TimeToSleepDuringGameplay); await Task.Delay(TimeToSleepDuringGameplay);
} }
try try