mirror of
https://github.com/osukey/osukey.git
synced 2025-07-01 08:20:00 +09:00
Only write when writes occur
Also add finaliser logic for safety. Also better threading. Also more cleanup.
This commit is contained in:
@ -19,10 +19,28 @@ namespace osu.Game.Database
|
||||
usageCompleted = onCompleted;
|
||||
}
|
||||
|
||||
public bool PerformedWrite { get; private set; }
|
||||
|
||||
private bool isDisposed;
|
||||
|
||||
protected void Dispose(bool disposing)
|
||||
{
|
||||
if (isDisposed) return;
|
||||
isDisposed = true;
|
||||
|
||||
PerformedWrite |= Context.SaveChanges(transaction) > 0;
|
||||
usageCompleted?.Invoke(this);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Context.SaveChanges(transaction);
|
||||
usageCompleted?.Invoke(this);
|
||||
Dispose(true);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
~DatabaseWriteUsage()
|
||||
{
|
||||
Dispose(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user