mirror of
https://github.com/vrm-c/UniVRM.git
synced 2026-09-08 11:59:26 -05:00
Add ThreadPoolScheduler
This commit is contained in:
42
Scripts/UniTask/ThreadPoolScheduler.cs
Normal file
42
Scripts/UniTask/ThreadPoolScheduler.cs
Normal file
@@ -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()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user