public void UnsafeOnCompleted(Action action) { if (continuation == null) { continuation = action; return; } else { if (continuation is Action act) { var q = new MinimumQueue<Action>(4); q.Enqueue(act); q.Enqueue(action); continuation = q; return; } else { ((MinimumQueue<Action>)continuation).Enqueue(action); } } }
public void AddAction(IPlayerLoopItem item) { lock (runningAndQueueLock) { if (running) { waitQueue.Enqueue(item); return; } } lock (arrayLock) { // Ensure Capacity if (loopItems.Length == tail) { Array.Resize(ref loopItems, checked(tail * 2)); } loopItems[tail++] = item; } }