mirror of
https://github.com/osukey/osukey.git
synced 2025-08-04 23:24:04 +09:00
Fix realm refetch operations potentially being unsafe
As seen in test failure https://github.com/ppy/osu/runs/6357384721?check_suite_focus=true.
This commit is contained in:
@ -344,6 +344,26 @@ namespace osu.Game.Database
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Write changes to realm.
|
||||
/// </summary>
|
||||
/// <param name="action">The work to run.</param>
|
||||
public T Write<T>(Func<Realm, T> action)
|
||||
{
|
||||
if (ThreadSafety.IsUpdateThread)
|
||||
{
|
||||
total_writes_update.Value++;
|
||||
return Realm.Write(action);
|
||||
}
|
||||
else
|
||||
{
|
||||
total_writes_async.Value++;
|
||||
|
||||
using (var realm = getRealmInstance())
|
||||
return realm.Write(action);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Write changes to realm.
|
||||
/// </summary>
|
||||
|
Reference in New Issue
Block a user