using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using Cysharp.Threading.Tasks;
using Plugins.JNGame.Sync.Frame.game;

namespace Game.Plugins.JNGame.Sync.Frame
{
    public class JNFrameUtil
    {
        //多线程并行
        public static async Task Parallel(List<IJNSyncFrameComponent> actions,int dt, JNFrameInfo frame)
        {
            List<Task> tasks = new();
            actions.ForEach(action =>
            {
                Task task;
                if ((task = action.OnSyncUpdateThread(dt, frame)) != null)
                {
                    tasks.Add(task);
                }
            });
            await Task.WhenAll(tasks);
        }
    }
}