internal static void _consume(EnumeratorQueue actions) { while (actions.Count > 0) { void _recurse(IEnumerator action) { try { while (action.MoveNext()) { try { _recurse((IEnumerator)action.Current); } catch (InvalidCastException e) { #if STAGEHAND_VERY_VERBOSE UnityEngine.Debug.LogException(e); #endif } catch (Exception e) { #if STAGEHAND_VERBOSE UnityEngine.Debug.LogException(e); #endif } } } catch (Exception e) { #if STAGEHAND_VERBOSE UnityEngine.Debug.LogException(e); #endif } } _recurse(actions.Dequeue()); } }
static Stage() { // Main Thread _queues[0] = new EnumeratorQueue("ThreadMain"); // The Rest... for (var processorIndex = 1; processorIndex < Environment.ProcessorCount; ++processorIndex) { new Thread(_consumer).Start(_queues[processorIndex] = new EnumeratorQueue($"Thread{processorIndex}")); } }