mirror of
https://github.com/ppy/osu.git
synced 2025-01-13 06:32:55 +08:00
Remove all calls to Realm.Refresh
to fix blocking overhead from subscriptions
Turns out this is not required if realm is aware of a `SynchronizationContext`. See https://github.com/realm/realm-dotnet/discussions/2775#discussioncomment-2005412 for further reading.
This commit is contained in:
parent
cab63830a1
commit
5df46d0a54
@ -46,9 +46,6 @@ namespace osu.Game.Database
|
||||
migrateScores(ef);
|
||||
}
|
||||
|
||||
Logger.Log("Refreshing realm...", LoggingTarget.Database);
|
||||
realmContextFactory.Refresh();
|
||||
|
||||
// Delete the database permanently.
|
||||
// Will cause future startups to not attempt migration.
|
||||
Logger.Log("Migration successful, deleting EF database", LoggingTarget.Database);
|
||||
|
@ -61,10 +61,10 @@ namespace osu.Game.Database
|
||||
|
||||
private readonly ThreadLocal<bool> currentThreadCanCreateContexts = new ThreadLocal<bool>();
|
||||
|
||||
private static readonly GlobalStatistic<int> refreshes = GlobalStatistics.Get<int>(@"Realm", @"Dirty Refreshes");
|
||||
private static readonly GlobalStatistic<int> contexts_created = GlobalStatistics.Get<int>(@"Realm", @"Contexts (Created)");
|
||||
|
||||
private readonly object contextLock = new object();
|
||||
|
||||
private Realm? context;
|
||||
|
||||
public Realm Context
|
||||
@ -169,18 +169,6 @@ namespace osu.Game.Database
|
||||
/// <returns></returns>
|
||||
public bool Compact() => Realm.Compact(getConfiguration());
|
||||
|
||||
/// <summary>
|
||||
/// Perform a blocking refresh on the main realm context.
|
||||
/// </summary>
|
||||
public void Refresh()
|
||||
{
|
||||
lock (contextLock)
|
||||
{
|
||||
if (context?.Refresh() == true)
|
||||
refreshes.Value++;
|
||||
}
|
||||
}
|
||||
|
||||
public Realm CreateContext()
|
||||
{
|
||||
if (isDisposed)
|
||||
|
@ -351,13 +351,6 @@ namespace osu.Game
|
||||
FrameStatistics.ValueChanged += e => fpsDisplayVisible.Value = e.NewValue != FrameStatisticsMode.None;
|
||||
}
|
||||
|
||||
protected override void Update()
|
||||
{
|
||||
base.Update();
|
||||
|
||||
realmFactory.Refresh();
|
||||
}
|
||||
|
||||
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent) =>
|
||||
dependencies = new DependencyContainer(base.CreateChildDependencies(parent));
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user