blob: 500c5bf8e69e89658db887403307295c77544d2f (
plain)
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
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using OpenSim.Region.OptionalModules.Scripting.Minimodule.Interfaces;
namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
{
public class MicroScheduler : IMicrothreader
{
private readonly List<IEnumerator> m_threads = new List<IEnumerator>();
public void Run(IEnumerable microthread)
{
lock (m_threads)
m_threads.Add(microthread.GetEnumerator());
}
public void Tick(int count)
{
lock (m_threads)
{
if(m_threads.Count == 0)
return;
int i = 0;
while (m_threads.Count > 0 && i < count)
{
i++;
bool running = m_threads[i%m_threads.Count].MoveNext();
if (!running)
m_threads.Remove(m_threads[i%m_threads.Count]);
}
}
}
}
}
|