fix: Fixes serialization threading, moves world save to end of loop, and eliminates Parallel.ForEach. (#1530)

This commit is contained in:
Kamron Batman 2023-10-03 00:42:49 -07:00 • committed by GitHub
parent e18115dd94
commit 1f0acddc46
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 228 additions and 58 deletions

View file

@ -36,6 +36,7 @@ public static class Core
{
private static readonly ILogger logger = LogFactory.GetLogger(typeof(Core));
private static bool _performSnapshot;
private static bool _crashed;
private static string _baseDirectory;
@ -556,6 +557,12 @@ public static class Core
Timer.CheckTimerPool(); // Check for pool depletion so we can async refill it.
if (_performSnapshot)
{
// Return value is the offset that can be used to fix timers that should drift
World.Snapshot();
}
_tickCount = 0;
_now = DateTime.MinValue;
@ -578,8 +585,14 @@ public static class Core
{
CurrentDomain_UnhandledException(null, new UnhandledExceptionEventArgs(e, true));
}
finally
{
World.SleepSerializationThreads();
}
}
internal static void RequestSnapshot() => _performSnapshot = true;
public static void VerifySerialization()
{
_itemCount = 0;