* Converts ClientManager.ForEach() (and as a result, Scene.ForEachClient()) to use a non-blocking parallel method when operating in async mode
* Minor code readability cleanup0.6.8-post-fixes
parent
322b39804d
commit
c75d415648
|
@ -204,7 +204,10 @@ namespace OpenSim.Framework
|
||||||
public void ForEach(Action<IClientAPI> action)
|
public void ForEach(Action<IClientAPI> action)
|
||||||
{
|
{
|
||||||
IClientAPI[] localArray = m_array;
|
IClientAPI[] localArray = m_array;
|
||||||
Parallel.ForEach<IClientAPI>(localArray, action);
|
Parallel.For(0, localArray.Length,
|
||||||
|
delegate(int i)
|
||||||
|
{ action(localArray[i]); }
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
@ -2105,12 +2105,14 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||||
public void SendViewerEffect(ViewerEffectPacket.EffectBlock[] effectBlocks)
|
public void SendViewerEffect(ViewerEffectPacket.EffectBlock[] effectBlocks)
|
||||||
{
|
{
|
||||||
ViewerEffectPacket packet = (ViewerEffectPacket)PacketPool.Instance.GetPacket(PacketType.ViewerEffect);
|
ViewerEffectPacket packet = (ViewerEffectPacket)PacketPool.Instance.GetPacket(PacketType.ViewerEffect);
|
||||||
packet.Effect = effectBlocks;
|
packet.Header.Reliable = false;
|
||||||
|
packet.Header.Zerocoded = true;
|
||||||
|
|
||||||
packet.AgentData.AgentID = AgentId;
|
packet.AgentData.AgentID = AgentId;
|
||||||
packet.AgentData.SessionID = SessionId;
|
packet.AgentData.SessionID = SessionId;
|
||||||
packet.Header.Reliable = false;
|
|
||||||
packet.Header.Zerocoded = true;
|
packet.Effect = effectBlocks;
|
||||||
|
|
||||||
OutPacket(packet, ThrottleOutPacketType.State);
|
OutPacket(packet, ThrottleOutPacketType.State);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -372,7 +372,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||||
OpenSim.Framework.LocklessQueue<OutgoingPacket> queue = m_packetOutboxes[category];
|
OpenSim.Framework.LocklessQueue<OutgoingPacket> queue = m_packetOutboxes[category];
|
||||||
TokenBucket bucket = m_throttleCategories[category];
|
TokenBucket bucket = m_throttleCategories[category];
|
||||||
|
|
||||||
if (m_throttleCategories[category].RemoveTokens(packet.Buffer.DataLength))
|
if (bucket.RemoveTokens(packet.Buffer.DataLength))
|
||||||
{
|
{
|
||||||
// Enough tokens were removed from the bucket, the packet will not be queued
|
// Enough tokens were removed from the bucket, the packet will not be queued
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -394,7 +394,7 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
void ProcessViewerEffect(IClientAPI remoteClient, List<ViewerEffectEventHandlerArg> args)
|
void ProcessViewerEffect(IClientAPI remoteClient, List<ViewerEffectEventHandlerArg> args)
|
||||||
{
|
{
|
||||||
// TODO: don't create new blocks if recycling an old packet
|
// TODO: don't create new blocks if recycling an old packet
|
||||||
List<ViewerEffectPacket.EffectBlock> effectBlock = new List<ViewerEffectPacket.EffectBlock>();
|
ViewerEffectPacket.EffectBlock[] effectBlockArray = new ViewerEffectPacket.EffectBlock[args.Count];
|
||||||
for (int i = 0; i < args.Count; i++)
|
for (int i = 0; i < args.Count; i++)
|
||||||
{
|
{
|
||||||
ViewerEffectPacket.EffectBlock effect = new ViewerEffectPacket.EffectBlock();
|
ViewerEffectPacket.EffectBlock effect = new ViewerEffectPacket.EffectBlock();
|
||||||
|
@ -404,9 +404,8 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
effect.ID = args[i].ID;
|
effect.ID = args[i].ID;
|
||||||
effect.Type = args[i].Type;
|
effect.Type = args[i].Type;
|
||||||
effect.TypeData = args[i].TypeData;
|
effect.TypeData = args[i].TypeData;
|
||||||
effectBlock.Add(effect);
|
effectBlockArray[i] = effect;
|
||||||
}
|
}
|
||||||
ViewerEffectPacket.EffectBlock[] effectBlockArray = effectBlock.ToArray();
|
|
||||||
|
|
||||||
ForEachClient(
|
ForEachClient(
|
||||||
delegate(IClientAPI client)
|
delegate(IClientAPI client)
|
||||||
|
|
Loading…
Reference in New Issue