Skip to content

Commit e9f577e

Browse files
committed
refactor: rewrite UDAPatchCollector
- Now runs on update instead of as a Coroutine using wait for end of frame - Uses concurrent stack for thread safety
1 parent 5159788 commit e9f577e

File tree

1 file changed

+7
-17
lines changed

1 file changed

+7
-17
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System.Collections;
1+
using System;
22
using UnityDebuggerAssistant.Patches;
33
using UnityDebuggerAssistant.Utils;
44
using UnityEngine;
@@ -13,33 +13,23 @@ private void Start()
1313
BepinExPluginMarshal.Run();
1414

1515
Plugin.Log?.LogInfo("UDA starting patch processor cycle");
16-
StartCoroutine(CheckPatches());
1716

1817
#if DEBUG
1918
UDAExceptionHandler.DebugThrow();
2019
#endif
2120
}
2221

23-
internal IEnumerator CheckPatches()
22+
private void Update()
2423
{
25-
yield return new WaitForEndOfFrame();
24+
var storage = ExceptionConstructorPatch.Storage;
2625

27-
if (ExceptionConstructorPatch.Storage.Count > 0)
26+
if (storage.TryPop(out Exception result))
2827
{
29-
3028
#if DEBUG
31-
Plugin.Log?.LogInfo($"No. to process {ExceptionConstructorPatch.Storage.Count}");
32-
#endif
33-
34-
foreach (var item in ExceptionConstructorPatch.Storage)
35-
{
36-
UDAExceptionHandler.Handle(item);
37-
}
38-
39-
ExceptionConstructorPatch.Storage.Clear();
29+
Plugin.Log?.LogInfo("Popping from stack this frame");
30+
#endif
31+
ExceptionProcessor.Run(result);
4032
}
4133

42-
StartCoroutine(CheckPatches());
43-
yield break;
4434
}
4535
}

0 commit comments

Comments
 (0)