diff options
author | Justin Clark-Casey (justincc) | 2014-08-13 23:45:51 +0100 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2014-08-13 23:45:51 +0100 |
commit | bc0895c758c8b206ecdd0139d982f3a5fe9b8672 (patch) | |
tree | 6487cd1eed000d0483959768e0f299e08865a264 /OpenSim/Region/Framework/Scenes/ScenePresence.cs | |
parent | Remove redundant origin region lock in SP.CompleteMovement() (diff) | |
download | opensim-SC_OLD-bc0895c758c8b206ecdd0139d982f3a5fe9b8672.zip opensim-SC_OLD-bc0895c758c8b206ecdd0139d982f3a5fe9b8672.tar.gz opensim-SC_OLD-bc0895c758c8b206ecdd0139d982f3a5fe9b8672.tar.bz2 opensim-SC_OLD-bc0895c758c8b206ecdd0139d982f3a5fe9b8672.tar.xz |
On entity transfer of scene presence, replace polling sleep in SP.WaitForUpdateAgent() with a triggered event instead.
Rapid polls are more expensive than triggered events (several polls vs one trigger) and may be problematic on heavily loaded simulators where many threads are vying for processor time.
A triggered event is also slightly quicker as there is no maximum 200ms wait between polls.
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/ScenePresence.cs')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/ScenePresence.cs | 27 |
1 files changed, 13 insertions, 14 deletions
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 5af7513..9ea0269 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs | |||
@@ -344,6 +344,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
344 | private object m_originRegionIDAccessLock = new object(); | 344 | private object m_originRegionIDAccessLock = new object(); |
345 | 345 | ||
346 | /// <summary> | 346 | /// <summary> |
347 | /// Triggered on entity transfer after to allow CompleteMovement() to proceed after we have received an | ||
348 | /// UpdateAgent from the originating region.ddkjjkj | ||
349 | /// </summary> | ||
350 | private AutoResetEvent m_updateAgentReceivedAfterTransferEvent = new AutoResetEvent(false); | ||
351 | |||
352 | /// <summary> | ||
347 | /// Used by the entity transfer module to signal when the presence should not be closed because a subsequent | 353 | /// Used by the entity transfer module to signal when the presence should not be closed because a subsequent |
348 | /// teleport is reusing the connection. | 354 | /// teleport is reusing the connection. |
349 | /// </summary> | 355 | /// </summary> |
@@ -1648,8 +1654,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1648 | // For the moment, just set the size as passed. | 1654 | // For the moment, just set the size as passed. |
1649 | PhysicsActor.Size = size; | 1655 | PhysicsActor.Size = size; |
1650 | // PhysicsActor.setAvatarSize(size, feetoffset); | 1656 | // PhysicsActor.setAvatarSize(size, feetoffset); |
1651 | } | 1657 | } |
1652 | |||
1653 | } | 1658 | } |
1654 | 1659 | ||
1655 | private bool WaitForUpdateAgent(IClientAPI client) | 1660 | private bool WaitForUpdateAgent(IClientAPI client) |
@@ -1658,20 +1663,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
1658 | // (which triggers Scene.IncomingUpdateChildAgent(AgentData cAgentData) here in the destination, | 1663 | // (which triggers Scene.IncomingUpdateChildAgent(AgentData cAgentData) here in the destination, |
1659 | // m_originRegionID is UUID.Zero; after, it's non-Zero. The CompleteMovement sequence initiated from the | 1664 | // m_originRegionID is UUID.Zero; after, it's non-Zero. The CompleteMovement sequence initiated from the |
1660 | // viewer (in turn triggered by the source region sending it a TeleportFinish event) waits until it's non-zero | 1665 | // viewer (in turn triggered by the source region sending it a TeleportFinish event) waits until it's non-zero |
1661 | int count = 50; | 1666 | m_updateAgentReceivedAfterTransferEvent.WaitOne(10000); |
1662 | UUID originID; | ||
1663 | 1667 | ||
1664 | lock (m_originRegionIDAccessLock) | 1668 | UUID originID = UUID.Zero; |
1665 | originID = m_originRegionID; | ||
1666 | 1669 | ||
1667 | while (originID.Equals(UUID.Zero) && count-- > 0) | 1670 | lock (m_originRegionIDAccessLock) |
1668 | { | 1671 | originID = m_originRegionID; |
1669 | lock (m_originRegionIDAccessLock) | ||
1670 | originID = m_originRegionID; | ||
1671 | |||
1672 | m_log.DebugFormat("[SCENE PRESENCE]: Agent {0} waiting for update in {1}", client.Name, Scene.Name); | ||
1673 | Thread.Sleep(200); | ||
1674 | } | ||
1675 | 1672 | ||
1676 | if (originID.Equals(UUID.Zero)) | 1673 | if (originID.Equals(UUID.Zero)) |
1677 | { | 1674 | { |
@@ -3820,6 +3817,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
3820 | return; | 3817 | return; |
3821 | 3818 | ||
3822 | CopyFrom(cAgentData); | 3819 | CopyFrom(cAgentData); |
3820 | |||
3821 | m_updateAgentReceivedAfterTransferEvent.Set(); | ||
3823 | } | 3822 | } |
3824 | 3823 | ||
3825 | private static Vector3 marker = new Vector3(-1f, -1f, -1f); | 3824 | private static Vector3 marker = new Vector3(-1f, -1f, -1f); |