using System;
using System.Collections.Generic;
namespace XGame.Framework.ThreadScheduler
{
///
/// 框架专用线程调度
///
internal class FrameworkSchedulers
{
private static Queue _queue;
internal static void RunOnMainThread(Action action)
{
if (_queue == null) _queue = new Queue();
_queue.Enqueue(action);
}
internal static void Update()
{
if (_queue == null)
return;
while (_queue.Count > 0)
{
_queue.Dequeue()?.Invoke();
}
}
internal static void Dispose()
{
_queue?.Clear();
}
}
}