mirror of
https://github.com/opensim/opensim.git
synced 2026-08-08 10:15:33 +08:00
mantis 3315: change the control of script flag running (needs testing)
This commit is contained in:
@@ -322,7 +322,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine
|
||||
(((m_HeapSize % 0x100000) * 1000)
|
||||
>> 20).ToString("D3"));
|
||||
|
||||
m_SleepThread = StartMyThread(RunSleepThread, "Yengine sleep" + " (" + sceneName + ")", ThreadPriority.Normal);
|
||||
m_SleepThread = StartMyThread(RunSleepThread, "Yengine sleep" + " (" + sceneName + ")", ThreadPriority.Normal, -1);
|
||||
for (int i = 0; i < numThreadScriptWorkers; i++)
|
||||
StartThreadWorker(i, m_workersPrio, sceneName);
|
||||
|
||||
@@ -1304,6 +1304,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine
|
||||
instance.m_Item = item;
|
||||
instance.m_DescName = part.Name + ":" + item.Name;
|
||||
instance.m_IState = XMRInstState.CONSTRUCT;
|
||||
instance.m_Running = item.ScriptRunning;
|
||||
|
||||
lock(m_InstancesDict)
|
||||
{
|
||||
@@ -1413,19 +1414,28 @@ namespace OpenSim.Region.ScriptEngine.Yengine
|
||||
// Put it on the start queue so it will run any queued event handlers,
|
||||
// such as state_entry() or on_rez(). If there aren't any queued, it
|
||||
// will just go to idle state when RunOne() tries to dequeue an event.
|
||||
lock(instance.m_QueueLock)
|
||||
{
|
||||
if(instance.m_IState != XMRInstState.CONSTRUCT)
|
||||
throw new Exception("bad state");
|
||||
instance.m_IState = XMRInstState.ONSTARTQ;
|
||||
if(!instance.m_Running)
|
||||
instance.EmptyEventQueues();
|
||||
}
|
||||
// Declare which events the script's current state can handle.
|
||||
|
||||
ulong eventMask = instance.GetStateEventFlags(instance.stateCode);
|
||||
instance.m_Part.SetScriptEvents(instance.m_ItemID, eventMask);
|
||||
|
||||
QueueToStart(instance);
|
||||
lock (instance.m_QueueLock)
|
||||
{
|
||||
if(instance.m_IState != XMRInstState.CONSTRUCT)
|
||||
throw new Exception("bad state");
|
||||
|
||||
if (instance.m_Running)
|
||||
{
|
||||
instance.m_Item.ScriptRunning = true;
|
||||
instance.m_IState = XMRInstState.ONSTARTQ;
|
||||
QueueToStart(instance);
|
||||
}
|
||||
else
|
||||
{
|
||||
instance.m_Item.ScriptRunning = false;
|
||||
instance.m_IState = XMRInstState.SUSPENDED;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void OnRemoveScript(uint localID, UUID itemID)
|
||||
@@ -1512,15 +1522,15 @@ namespace OpenSim.Region.ScriptEngine.Yengine
|
||||
{
|
||||
TraceCalls("[YEngine]: YEngine.OnGetScriptRunning({0},{1})", objectID.ToString(), itemID.ToString());
|
||||
|
||||
bool curRunnning = instance.Running & instance.m_Item.ScriptRunning;
|
||||
IEventQueue eq = World.RequestModuleInterface<IEventQueue>();
|
||||
if(eq == null)
|
||||
{
|
||||
controllingClient.SendScriptRunningReply(objectID, itemID,
|
||||
instance.Running);
|
||||
controllingClient.SendScriptRunningReply(objectID, itemID, curRunnning);
|
||||
}
|
||||
else
|
||||
{
|
||||
eq.ScriptRunningEvent(objectID, itemID, instance.Running, controllingClient.AgentId);
|
||||
eq.ScriptRunningEvent(objectID, itemID, curRunnning, controllingClient.AgentId);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2033,10 +2043,10 @@ namespace OpenSim.Region.ScriptEngine.Yengine
|
||||
/**
|
||||
* @brief Manage our threads.
|
||||
*/
|
||||
public static Thread StartMyThread(ThreadStart start, string name, ThreadPriority priority)
|
||||
public static Thread StartMyThread(ThreadStart start, string name, ThreadPriority priority, int stackSize)
|
||||
{
|
||||
m_log.Debug("[YEngine]: starting thread " + name);
|
||||
Thread thread = WorkManager.StartThread(start, name, priority, false, false);
|
||||
Thread thread = WorkManager.StartThread(start, name, priority, stackSize);
|
||||
return thread;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user