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:
Dean Herbert 2022-01-20 20:23:17 +09:00
parent cab63830a1
commit 5df46d0a54
3 changed files with 1 additions and 23 deletions

View File

@ -46,9 +46,6 @@ public void Run()
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);

View File

@ -61,10 +61,10 @@ public class RealmContextFactory : IDisposable, IRealmFactory
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 @@ private void cleanupPendingDeletions()
/// <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)

View File

@ -351,13 +351,6 @@ protected override void LoadComplete()
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));