Files
back_cantanBuilding/LocalPackages/rtm-sdk-unity-2.7.20/Runtime/Plugins/rtm/RTMCallbackQueue.cs
2026-05-26 16:15:54 +08:00

48 lines
957 B
C#

using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace com.fpnn.rtm
{
public class RTMCallbackQueue : MonoBehaviour
{
private static Queue<Action> actionQueue = new Queue<Action>();
public void Clear()
{
lock (actionQueue)
{
actionQueue.Clear();
}
}
public void PostAction(Action action)
{
lock (actionQueue)
{
actionQueue.Enqueue(action);
}
}
private Action GetAction()
{
lock (actionQueue)
{
Action action = actionQueue.Dequeue();
return action;
}
}
void Update()
{
while (actionQueue.Count > 0)
{
Action action = GetAction();
action();
}
}
}
}