12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394 |
- using System.Collections.Generic;
- namespace Fort23.Core
- {
- public static class CTaskHelper
- {
- // private class CoroutineBlocker
- // {
- // private int count;
- //
- // private List<CTask> tcss = new List<CTask>();
- //
- // public CoroutineBlocker(int count)
- // {
- // this.count = count;
- // }
- //
- // public async CTask WaitAsync()
- // {
- // --this.count;
- // if (this.count < 0)
- // {
- // return;
- // }
- //
- // if (this.count == 0)
- // {
- // List<CTask> t = this.tcss;
- // this.tcss = null;
- // foreach (CTask ttcs in t)
- // {
- // ttcs.SetResult();
- // }
- //
- // return;
- // }
- //
- // CTask tcs = CTask.Create();
- //
- // tcss.Add(tcs);
- // await tcs;
- // }
- // }
-
- // public static async CTask<bool> WaitAll<T>(List<CTask<T>> tasks)
- // {
- // if (tasks.Count == 0)
- // {
- // return false;
- // }
- //
- // CoroutineBlocker coroutineBlocker = new CoroutineBlocker(tasks.Count + 1);
- // foreach (CTask<T> task in tasks)
- // {
- // RunOneTask(task);
- // }
- //
- // async void RunOneTask(CTask<T> task)
- // {
- // await task;
- // await coroutineBlocker.WaitAsync();
- // }
- // await coroutineBlocker.WaitAsync();
- // return true;
- // }
-
- // public static async CTask<bool> WaitAll(List<CTask> tasks)
- // {
- // if (tasks.Count == 0)
- // {
- // return false;
- // }
- //
- // CoroutineBlocker coroutineBlocker = new CoroutineBlocker(tasks.Count + 1);
- // foreach (CTask task in tasks)
- // {
- // RunOneTask(task);
- //
- // }
- //
- // await coroutineBlocker.WaitAsync();
- //
- // async void RunOneTask(CTask task)
- // {
- // await task;
- // await coroutineBlocker.WaitAsync();
- // }
- // return true;
- // }
- }
- }
|