diff --git a/Scripts/UniTask/ThreadPoolScheduler.cs b/Scripts/UniTask/ThreadPoolScheduler.cs new file mode 100644 index 000000000..94e6316e7 --- /dev/null +++ b/Scripts/UniTask/ThreadPoolScheduler.cs @@ -0,0 +1,42 @@ +using System; + +namespace UniTask +{ + public static partial class Scheduler + { + private static IScheduler threadPool; + + public static IScheduler ThreadPool + { + get { return threadPool ?? (threadPool = new ThreadPoolScheduler()); } + } + + public class ThreadPoolScheduler : IScheduler + { + public void Enqueue(TaskChain item) + { + System.Threading.ThreadPool.QueueUserWorkItem(_ => + { + if (item == null) + { + return; + } + + while (true) + { + var status = item.Next(); + if (status != ExecutionStatus.Continue) + { + break; + } + } + + }); + } + + public void Dispose() + { + } + } + } +}