Mainly more hauling optimizations, utilizing linked storage groups

This also adds an experimental, usually slower, threaded gas grid mode and implements a workaround for the whole mod and game failing to start when opening prepatcher's mod manager with unfortunate timing
This commit is contained in:
bbradson
2024-02-01 19:57:50 +01:00
parent 20aebe4e83
commit 949bde76ce
27 changed files with 451 additions and 280 deletions
+12 -4
View File
@@ -100,6 +100,15 @@ public static class ParallelNoAlloc
return monitorObject;
}
public static bool HasAnyRegisteredWorkers(object? monitorObject)
{
Guard.IsNotNull(monitorObject);
return monitorObject is MonitorObject.Group typedMonitorObject
? typedMonitorObject.Subscribers.Length > 0
: ThrowHelper.ThrowArgumentException<bool>();
}
public static void DeregisterBackgroundWaitingWorker(object monitorObject, Action action)
{
Guard.IsNotNull(action);
@@ -140,6 +149,8 @@ public static class ParallelNoAlloc
typedMonitorObject.Pulse();
}
internal static void ClearAll() => _groupWorkers.Clear();
private abstract class Worker : IFishPoolable
{
public Thread Thread { get; private set; }
@@ -217,13 +228,10 @@ public static class ParallelNoAlloc
public void Invoke(Action action)
{
Guard.IsNotAssignableToType<MonitorObject.Group>(MonitorObject);
if (Pulsed)
Spin();
Action = action;
MonitorObject.Pulse();
}