StepScheduler.cs
1.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
namespace DepthFirstScheduler
{
public static partial class Scheduler
{
private static StepScheduler mainThread;
public static StepScheduler MainThread
{
get
{
if (mainThread != null) return mainThread;
mainThread = new StepScheduler();
MainThreadDispatcher.Initialize();
return mainThread;
}
}
public class StepScheduler : IScheduler
{
LockQueue<TaskChain> m_taskQueue = new LockQueue<TaskChain>();
public void Enqueue(TaskChain item)
{
m_taskQueue.Enqueue(item);
}
TaskChain m_chain;
public int UpdateAndGetTaskCount()
{
if (m_chain != null)
{
var status = m_chain.Next();
if (status == ExecutionStatus.Continue)
{
// m_item継続中
return m_taskQueue.Count;
}
m_chain = null;
}
int count;
m_chain = m_taskQueue.Dequeue(out count);
return count;
}
public void Dispose()
{
}
}
}
}