Move BeatmapOnlineLookupQueue to inside BeatmapUpdater

This commit is contained in:
Dean Herbert 2022-06-30 17:03:19 +09:00
parent ef42c6ecdf
commit 0698471627
2 changed files with 20 additions and 7 deletions

View File

@ -41,7 +41,6 @@ namespace osu.Game.Beatmaps
private readonly BeatmapImporter beatmapImporter;
private readonly WorkingBeatmapCache workingBeatmapCache;
private readonly BeatmapOnlineLookupQueue? onlineBeatmapLookupQueue;
private readonly BeatmapUpdater? beatmapUpdater;
public BeatmapManager(Storage storage, RealmAccess realm, RulesetStore rulesets, IAPIProvider? api, AudioManager audioManager, IResourceStore<byte[]> gameResources, GameHost? host = null,
@ -56,8 +55,7 @@ namespace osu.Game.Beatmaps
if (difficultyCache == null)
throw new ArgumentNullException(nameof(difficultyCache), "Difficulty cache must be provided if online lookups are required.");
onlineBeatmapLookupQueue = new BeatmapOnlineLookupQueue(api, storage);
beatmapUpdater = new BeatmapUpdater(this, onlineBeatmapLookupQueue, difficultyCache);
beatmapUpdater = new BeatmapUpdater(this, difficultyCache, api, storage);
}
var userResources = new RealmFileStore(realm, storage).Store;
@ -474,7 +472,7 @@ namespace osu.Game.Beatmaps
public void Dispose()
{
onlineBeatmapLookupQueue?.Dispose();
beatmapUpdater?.Dispose();
}
#endregion

View File

@ -1,10 +1,14 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using System;
using System.Diagnostics;
using System.Linq;
using System.Threading.Tasks;
using osu.Framework.Extensions.ObjectExtensions;
using osu.Framework.Platform;
using osu.Game.Database;
using osu.Game.Online.API;
using osu.Game.Rulesets.Objects;
using Realms;
@ -13,17 +17,18 @@ namespace osu.Game.Beatmaps
/// <summary>
/// Handles all processing required to ensure a local beatmap is in a consistent state with any changes.
/// </summary>
public class BeatmapUpdater
public class BeatmapUpdater : IDisposable
{
private readonly IWorkingBeatmapCache workingBeatmapCache;
private readonly BeatmapOnlineLookupQueue onlineLookupQueue;
private readonly BeatmapDifficultyCache difficultyCache;
public BeatmapUpdater(IWorkingBeatmapCache workingBeatmapCache, BeatmapOnlineLookupQueue onlineLookupQueue, BeatmapDifficultyCache difficultyCache)
public BeatmapUpdater(IWorkingBeatmapCache workingBeatmapCache, BeatmapDifficultyCache difficultyCache, IAPIProvider api, Storage storage)
{
this.workingBeatmapCache = workingBeatmapCache;
this.onlineLookupQueue = onlineLookupQueue;
this.difficultyCache = difficultyCache;
onlineLookupQueue = new BeatmapOnlineLookupQueue(api, storage);
}
/// <summary>
@ -81,5 +86,15 @@ namespace osu.Game.Beatmaps
return endTime - startTime;
}
#region Implementation of IDisposable
public void Dispose()
{
if (onlineLookupQueue.IsNotNull())
onlineLookupQueue.Dispose();
}
#endregion
}
}