* Tweaks to Java engine (uses less threads). Added support for OnFrame and OnNewPresence events.
parent
c570b107f8
commit
ad86e94b3d
|
@ -47,11 +47,6 @@ namespace OpenSim.Scripting.EmbeddedJVM
|
|||
|
||||
ScriptInfo scriptInfo;
|
||||
|
||||
public JVMScript()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void Initialise(ScriptInfo info)
|
||||
{
|
||||
scriptInfo = info;
|
||||
|
@ -59,10 +54,42 @@ namespace OpenSim.Scripting.EmbeddedJVM
|
|||
_mainMemory = new MainMemory();
|
||||
Thread.GlobalMemory = this._mainMemory;
|
||||
Thread.World = info.world;
|
||||
compileThread = new System.Threading.Thread(new ThreadStart(CompileScript));
|
||||
compileThread.IsBackground = true;
|
||||
compileThread.Start();
|
||||
CompileScript();
|
||||
|
||||
scriptInfo.events.OnFrame += new EventManager.OnFrameDelegate(events_OnFrame);
|
||||
scriptInfo.events.OnNewPresence += new EventManager.OnNewPresenceDelegate(events_OnNewPresence);
|
||||
}
|
||||
|
||||
void events_OnNewPresence(ScenePresence presence)
|
||||
{
|
||||
for (int i = 0; i < this._threads.Count; i++)
|
||||
{
|
||||
if (!this._threads[i].running)
|
||||
{
|
||||
this._threads[i].StartMethod("OnNewPresence");
|
||||
bool run = true;
|
||||
while (run)
|
||||
{
|
||||
run = this._threads[i].Excute();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void events_OnFrame()
|
||||
{
|
||||
for (int i = 0; i < this._threads.Count; i++)
|
||||
{
|
||||
if (!this._threads[i].running)
|
||||
{
|
||||
this._threads[i].StartMethod("OnFrame");
|
||||
bool run = true;
|
||||
while (run)
|
||||
{
|
||||
run = this._threads[i].Excute();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public string getName()
|
||||
|
@ -80,8 +107,6 @@ namespace OpenSim.Scripting.EmbeddedJVM
|
|||
}
|
||||
|
||||
public void CompileScript()
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
CompileInfo comp = this.CompileScripts.Dequeue();
|
||||
string script = comp.script;
|
||||
|
@ -131,23 +156,6 @@ namespace OpenSim.Scripting.EmbeddedJVM
|
|||
Console.WriteLine(e.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void OnFrame()
|
||||
{
|
||||
for (int i = 0; i < this._threads.Count; i++)
|
||||
{
|
||||
if (!this._threads[i].running)
|
||||
{
|
||||
this._threads[i].StartMethod("OnFrame");
|
||||
bool run = true;
|
||||
while (run)
|
||||
{
|
||||
run = this._threads[i].Excute();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class CompileInfo
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue