Update svn properties.
parent
d8313e314f
commit
6077bbda30
|
@ -1,12 +1,12 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
namespace OpenSim.Region.OptionalModules.Scripting.Minimodule.Interfaces
|
namespace OpenSim.Region.OptionalModules.Scripting.Minimodule.Interfaces
|
||||||
{
|
{
|
||||||
public interface IMicrothreader
|
public interface IMicrothreader
|
||||||
{
|
{
|
||||||
void Run(IEnumerable microthread);
|
void Run(IEnumerable microthread);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,38 +1,38 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using OpenSim.Region.OptionalModules.Scripting.Minimodule.Interfaces;
|
using OpenSim.Region.OptionalModules.Scripting.Minimodule.Interfaces;
|
||||||
|
|
||||||
namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
|
namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
|
||||||
{
|
{
|
||||||
public class MicroScheduler : IMicrothreader
|
public class MicroScheduler : IMicrothreader
|
||||||
{
|
{
|
||||||
private readonly List<IEnumerator> m_threads = new List<IEnumerator>();
|
private readonly List<IEnumerator> m_threads = new List<IEnumerator>();
|
||||||
|
|
||||||
public void Run(IEnumerable microthread)
|
public void Run(IEnumerable microthread)
|
||||||
{
|
{
|
||||||
lock (m_threads)
|
lock (m_threads)
|
||||||
m_threads.Add(microthread.GetEnumerator());
|
m_threads.Add(microthread.GetEnumerator());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Tick(int count)
|
public void Tick(int count)
|
||||||
{
|
{
|
||||||
lock (m_threads)
|
lock (m_threads)
|
||||||
{
|
{
|
||||||
if(m_threads.Count == 0)
|
if(m_threads.Count == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
while (m_threads.Count > 0 && i < count)
|
while (m_threads.Count > 0 && i < count)
|
||||||
{
|
{
|
||||||
i++;
|
i++;
|
||||||
bool running = m_threads[i%m_threads.Count].MoveNext();
|
bool running = m_threads[i%m_threads.Count].MoveNext();
|
||||||
|
|
||||||
if (!running)
|
if (!running)
|
||||||
m_threads.Remove(m_threads[i%m_threads.Count]);
|
m_threads.Remove(m_threads[i%m_threads.Count]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,40 +1,40 @@
|
||||||
//MRM:C#
|
//MRM:C#
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using OpenSim.Region.OptionalModules.Scripting.Minimodule;
|
using OpenSim.Region.OptionalModules.Scripting.Minimodule;
|
||||||
|
|
||||||
namespace OpenSim
|
namespace OpenSim
|
||||||
{
|
{
|
||||||
class MiniModule : MRMBase
|
class MiniModule : MRMBase
|
||||||
{
|
{
|
||||||
public microthreaded void MicroThreadFunction(string testparam)
|
public microthreaded void MicroThreadFunction(string testparam)
|
||||||
{
|
{
|
||||||
Host.Object.Say("Hello " + testparam);
|
Host.Object.Say("Hello " + testparam);
|
||||||
|
|
||||||
relax; // the 'relax' keyword gives up processing time.
|
relax; // the 'relax' keyword gives up processing time.
|
||||||
// and should be inserted before, after or in
|
// and should be inserted before, after or in
|
||||||
// any computationally "heavy" zones.
|
// any computationally "heavy" zones.
|
||||||
|
|
||||||
int c = 500;
|
int c = 500;
|
||||||
while(c-- < 0) {
|
while(c-- < 0) {
|
||||||
Host.Object.Say("C=" + c);
|
Host.Object.Say("C=" + c);
|
||||||
relax; // Putting 'relax' in microthreaded loops
|
relax; // Putting 'relax' in microthreaded loops
|
||||||
// is an easy way to lower the CPU tax
|
// is an easy way to lower the CPU tax
|
||||||
// on your script.
|
// on your script.
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Start()
|
public override void Start()
|
||||||
{
|
{
|
||||||
Host.Microthreads.Run(
|
Host.Microthreads.Run(
|
||||||
MicroThreadFunction("World!")
|
MicroThreadFunction("World!")
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Stop()
|
public override void Stop()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue