Esempio n. 1
0
 private bool RemoveFinishedTask(LiteTask task)
 {
     if (!task.IsDone)
     {
         return(false);
     }
     task.RestartTask(null, true);
     pool.Push(task);
     return(true);
 }
Esempio n. 2
0
        public void Release(LiteTask task)
        {
            lock (pool)
            {
                if (task != null && set.Add(task))
                {
                    task.Cancel();

                    if (task.IsDone)
                    {
                        task.RestartTask(null, true);
                        pool.Push(task);
                    }
                    else
                    {
                        if (runningTasks == null)
                        {
                            runningTasks = new List <LiteTask>()
                            {
                                task
                            };
                            removeFinishedTask = RemoveFinishedTask;
                        }
                        else
                        {
                            runningTasks.Add(task);
                        }

                        if (waitRoutine.IsNullOrDone())
                        {
                            LiteCoroutine.StartCoroutine(ref waitRoutine, WaitForTasks());
                        }
                    }
                }
            }
        }