From eb776ab880765ff3955c5740e14649ed31e247b7 Mon Sep 17 00:00:00 2001 From: Creeper Lv Date: Sat, 19 Feb 2022 02:51:30 +0800 Subject: [PATCH 1/2] Added a flag to indicate if Dispatcher is inited. --- CLUNL.Unity3D/Sync/Dispatcher.cs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/CLUNL.Unity3D/Sync/Dispatcher.cs b/CLUNL.Unity3D/Sync/Dispatcher.cs index 4674d47..fabb461 100644 --- a/CLUNL.Unity3D/Sync/Dispatcher.cs +++ b/CLUNL.Unity3D/Sync/Dispatcher.cs @@ -12,6 +12,17 @@ public class Dispatcher //static ImmutableQueue iactions = ImmutableQueue.Empty; static ConcurrentQueue actions = new ConcurrentQueue(); static object _lock = new object(); + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static bool Inited() + { + return init; + } + static bool init = false; + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static void MarkInit() + { + init = true; + } /// /// Call to perform a sync operation every frame. /// From 206c8d4490937deee88b20470d2408e8f3717b3c Mon Sep 17 00:00:00 2001 From: Creeper Lv Date: Sat, 19 Feb 2022 03:10:53 +0800 Subject: [PATCH 2/2] Fixed the problem that DispatcherController won't mark Dispatcher as inited. --- CLUNL.Unity3D/Sync/DispatcherController.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/CLUNL.Unity3D/Sync/DispatcherController.cs b/CLUNL.Unity3D/Sync/DispatcherController.cs index 04d91c6..7df2025 100644 --- a/CLUNL.Unity3D/Sync/DispatcherController.cs +++ b/CLUNL.Unity3D/Sync/DispatcherController.cs @@ -15,6 +15,7 @@ public void Start() Destroy(gameObject); return; } + Dispatcher.MarkInit(); DontDestroyOnLoad(gameObject); } public void Update()