mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 12:33:01 +08:00
Also add logging of realm block/flush operations
This commit is contained in:
parent
9acc5e38bb
commit
2f1203085b
@ -89,12 +89,18 @@ namespace osu.Game.Database
|
|||||||
if (IsDisposed)
|
if (IsDisposed)
|
||||||
throw new ObjectDisposedException(nameof(RealmContextFactory));
|
throw new ObjectDisposedException(nameof(RealmContextFactory));
|
||||||
|
|
||||||
|
Logger.Log(@"Blocking realm operations.", LoggingTarget.Database);
|
||||||
|
|
||||||
blockingLock.Wait();
|
blockingLock.Wait();
|
||||||
flushContexts();
|
flushContexts();
|
||||||
|
|
||||||
return new InvokeOnDisposal<RealmContextFactory>(this, endBlockingSection);
|
return new InvokeOnDisposal<RealmContextFactory>(this, endBlockingSection);
|
||||||
|
|
||||||
static void endBlockingSection(RealmContextFactory factory) => factory.blockingLock.Release();
|
static void endBlockingSection(RealmContextFactory factory)
|
||||||
|
{
|
||||||
|
factory.blockingLock.Release();
|
||||||
|
Logger.Log(@"Restoring realm operations.", LoggingTarget.Database);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void Update()
|
protected override void Update()
|
||||||
@ -147,6 +153,8 @@ namespace osu.Game.Database
|
|||||||
|
|
||||||
private void flushContexts()
|
private void flushContexts()
|
||||||
{
|
{
|
||||||
|
Logger.Log(@"Flushing realm contexts...", LoggingTarget.Database);
|
||||||
|
|
||||||
var previousContext = context;
|
var previousContext = context;
|
||||||
context = null;
|
context = null;
|
||||||
|
|
||||||
@ -155,6 +163,8 @@ namespace osu.Game.Database
|
|||||||
Thread.Sleep(50);
|
Thread.Sleep(50);
|
||||||
|
|
||||||
previousContext?.Dispose();
|
previousContext?.Dispose();
|
||||||
|
|
||||||
|
Logger.Log(@"Realm contexts flushed.", LoggingTarget.Database);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void Dispose(bool isDisposing)
|
protected override void Dispose(bool isDisposing)
|
||||||
|
Loading…
Reference in New Issue
Block a user