mirror of
https://github.com/ppy/osu.git
synced 2025-01-29 05:52:56 +08:00
Update execution state change blocking logic in line with framework changes
This commit is contained in:
parent
6922de12c6
commit
57ae87956a
@ -24,6 +24,7 @@ using osu.Framework.Graphics.Performance;
|
|||||||
using osu.Framework.Graphics.Textures;
|
using osu.Framework.Graphics.Textures;
|
||||||
using osu.Framework.Input;
|
using osu.Framework.Input;
|
||||||
using osu.Framework.Logging;
|
using osu.Framework.Logging;
|
||||||
|
using osu.Framework.Threading;
|
||||||
using osu.Game.Audio;
|
using osu.Game.Audio;
|
||||||
using osu.Game.Database;
|
using osu.Game.Database;
|
||||||
using osu.Game.Input;
|
using osu.Game.Input;
|
||||||
@ -156,6 +157,8 @@ namespace osu.Game
|
|||||||
|
|
||||||
private readonly BindableNumber<double> globalTrackVolumeAdjust = new BindableNumber<double>(GLOBAL_TRACK_VOLUME_ADJUST);
|
private readonly BindableNumber<double> globalTrackVolumeAdjust = new BindableNumber<double>(GLOBAL_TRACK_VOLUME_ADJUST);
|
||||||
|
|
||||||
|
private IBindable<GameThreadState> updateThreadState;
|
||||||
|
|
||||||
public OsuGameBase()
|
public OsuGameBase()
|
||||||
{
|
{
|
||||||
UseDevelopmentServer = DebugUtils.IsDebugBuild;
|
UseDevelopmentServer = DebugUtils.IsDebugBuild;
|
||||||
@ -183,7 +186,8 @@ namespace osu.Game
|
|||||||
|
|
||||||
dependencies.Cache(realmFactory = new RealmContextFactory(Storage));
|
dependencies.Cache(realmFactory = new RealmContextFactory(Storage));
|
||||||
|
|
||||||
Host.UpdateThread.ThreadPausing += onUpdateThreadPausing;
|
updateThreadState = Host.UpdateThread.State.GetBoundCopy();
|
||||||
|
updateThreadState.BindValueChanged(updateThreadStateChanged);
|
||||||
|
|
||||||
AddInternal(realmFactory);
|
AddInternal(realmFactory);
|
||||||
|
|
||||||
@ -359,10 +363,21 @@ namespace osu.Game
|
|||||||
Ruleset.BindValueChanged(onRulesetChanged);
|
Ruleset.BindValueChanged(onRulesetChanged);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onUpdateThreadPausing()
|
private IDisposable blocking;
|
||||||
|
|
||||||
|
private void updateThreadStateChanged(ValueChangedEvent<GameThreadState> state)
|
||||||
{
|
{
|
||||||
var blocking = realmFactory.BlockAllOperations();
|
switch (state.NewValue)
|
||||||
Schedule(() => blocking.Dispose());
|
{
|
||||||
|
case GameThreadState.Running:
|
||||||
|
blocking.Dispose();
|
||||||
|
blocking = null;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case GameThreadState.Paused:
|
||||||
|
blocking = realmFactory.BlockAllOperations();
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void LoadComplete()
|
protected override void LoadComplete()
|
||||||
@ -498,9 +513,6 @@ namespace osu.Game
|
|||||||
LocalConfig?.Dispose();
|
LocalConfig?.Dispose();
|
||||||
|
|
||||||
contextFactory.FlushConnections();
|
contextFactory.FlushConnections();
|
||||||
|
|
||||||
if (Host?.UpdateThread != null)
|
|
||||||
Host.UpdateThread.ThreadPausing -= onUpdateThreadPausing;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user