From 9e079d2e2fd944ad986538656a68d2ee8433e4b1 Mon Sep 17 00:00:00 2001 From: Momo the Monster Date: Wed, 30 Mar 2022 13:49:24 -0700 Subject: [PATCH] Adds ClearQueue method to reinitialize m_MainThreadQueue Also turns the default queue size into a const so it can be referred to in both places. --- Runtime/Scripts/OscServer.cs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Runtime/Scripts/OscServer.cs b/Runtime/Scripts/OscServer.cs index cba77dc..b9c1ea9 100644 --- a/Runtime/Scripts/OscServer.cs +++ b/Runtime/Scripts/OscServer.cs @@ -25,8 +25,9 @@ public sealed unsafe class OscServer : IDisposable GCHandle m_BufferHandle; byte* m_BufferPtr; - Action[] m_MainThreadQueue = new Action[16]; + Action[] m_MainThreadQueue = new Action[mainThreadQueueSize]; int m_MainThreadCount; + private const int mainThreadQueueSize = 16; readonly Dictionary m_ByteLengthToStringBuffer = new Dictionary(); @@ -111,6 +112,13 @@ public static bool Remove(int port) } return false; } + + /// Clear the MainThreadQueue of an OSC Server + public void ClearQueue() + { + m_MainThreadCount = 0; + m_MainThreadQueue = new Action[mainThreadQueueSize]; + } /// /// Register a single background thread method for an OSC address