From f510ef9153618d238ea534edb943b1c732b95690 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 5 Jul 2021 10:49:55 +0900 Subject: [PATCH] Move `previousContext` assign within `lock` to make things look safer Not an actual requirement, but no harm. --- osu.Game/Database/RealmContextFactory.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/osu.Game/Database/RealmContextFactory.cs b/osu.Game/Database/RealmContextFactory.cs index b0241fb93c..ed3dc01f15 100644 --- a/osu.Game/Database/RealmContextFactory.cs +++ b/osu.Game/Database/RealmContextFactory.cs @@ -2,6 +2,7 @@ // See the LICENCE file in the repository root for full licence text. using System; +using System.Diagnostics; using System.Threading; using osu.Framework.Allocation; using osu.Framework.Development; @@ -166,11 +167,15 @@ namespace osu.Game.Database private void flushContexts() { Logger.Log(@"Flushing realm contexts...", LoggingTarget.Database); + Debug.Assert(blockingLock.CurrentCount == 0); - var previousContext = context; + Realm previousContext; lock (updateContextLock) + { + previousContext = context; context = null; + } // wait for all threaded usages to finish while (active_usages.Value > 0)