UniVRM/DepthFirstScheduler/Scheduler/ThreadPoolScheduler.cs
ousttrue d43d135c80 Merge commit 'f20f27259c28dbff6697958b8727d39d24f74ce1' as 'DepthFirstScheduler'
Co-authored-by: ousttrue <ousttrue@gmail.com>
Co-authored-by: TORISOUP <tori.birdstrike@gmail.com>
Co-authored-by: yutopp <yutopp@gmail.com>
2018-12-28 21:17:47 +09:00

43 lines
1013 B
C#

using System;
namespace DepthFirstScheduler
{
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()
{
}
}
}
}