1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 10:12:54 +08:00

Don't dispose read contexts

This commit is contained in:
Dean Herbert 2018-02-13 15:08:45 +09:00
parent ab34123ba8
commit 50cdb03cd9

View File

@ -56,7 +56,11 @@ namespace osu.Game.Database
if (currentWriteDidWrite)
{
// explicitly dispose to ensure any outstanding flushes happen as soon as possible (and underlying resources are purged).
usage.Context.Dispose();
currentWriteDidWrite = false;
// once all writes are complete, we want to refresh thread-specific contexts to make sure they don't have stale local caches.
recycleThreadContexts();
}
@ -67,14 +71,7 @@ namespace osu.Game.Database
}
}
private void recycleThreadContexts()
{
if (threadContexts != null)
foreach (var context in threadContexts.Values)
context.Dispose();
threadContexts = new ThreadLocal<OsuDbContext>(CreateContext, true);
}
private void recycleThreadContexts() => threadContexts = new ThreadLocal<OsuDbContext>(CreateContext);
protected virtual OsuDbContext CreateContext()
{