refactor: move world comm message queueing into its own method

mysql-performance
Justin Clark-Casey (justincc) 2010-02-02 20:38:58 +00:00
parent 0faeaf98a6
commit bbd41de6d5
1 changed files with 13 additions and 23 deletions

View File

@ -262,44 +262,34 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm
{ {
case ChatTypeEnum.Whisper: case ChatTypeEnum.Whisper:
if (dis < m_whisperdistance) if (dis < m_whisperdistance)
{ QueueMessage(new ListenerInfo(li, name, id, msg));
lock (m_pending.SyncRoot)
{
m_pending.Enqueue(new ListenerInfo(li,name,id,msg));
}
}
break; break;
case ChatTypeEnum.Say: case ChatTypeEnum.Say:
if (dis < m_saydistance) if (dis < m_saydistance)
{ QueueMessage(new ListenerInfo(li, name, id, msg));
lock (m_pending.SyncRoot)
{
m_pending.Enqueue(new ListenerInfo(li,name,id,msg));
}
}
break; break;
case ChatTypeEnum.Shout: case ChatTypeEnum.Shout:
if (dis < m_shoutdistance) if (dis < m_shoutdistance)
{ QueueMessage(new ListenerInfo(li, name, id, msg));
lock (m_pending.SyncRoot)
{
m_pending.Enqueue(new ListenerInfo(li,name,id,msg));
}
}
break; break;
case ChatTypeEnum.Region: case ChatTypeEnum.Region:
lock (m_pending.SyncRoot) QueueMessage(new ListenerInfo(li, name, id, msg));
{
m_pending.Enqueue(new ListenerInfo(li,name,id,msg));
}
break; break;
} }
} }
} }
protected void QueueMessage(ListenerInfo li)
{
lock (m_pending.SyncRoot)
{
m_pending.Enqueue(li);
}
}
/// <summary> /// <summary>
/// Are there any listen events ready to be dispatched? /// Are there any listen events ready to be dispatched?
/// </summary> /// </summary>
@ -319,7 +309,7 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm
lock (m_pending.SyncRoot) lock (m_pending.SyncRoot)
{ {
li = (ListenerInfo) m_pending.Dequeue(); li = (ListenerInfo)m_pending.Dequeue();
} }
return li; return li;