diff options
author | UbitUmarov | 2019-01-06 01:23:08 +0000 |
---|---|---|
committer | UbitUmarov | 2019-01-06 01:23:08 +0000 |
commit | c5604d38573e6723e668073be6553ebfa7354a09 (patch) | |
tree | 73e875392e02f575bae7cbc755218ccdf539967c /OpenSim/Region | |
parent | change mapandarray array update time (diff) | |
download | opensim-SC-c5604d38573e6723e668073be6553ebfa7354a09.zip opensim-SC-c5604d38573e6723e668073be6553ebfa7354a09.tar.gz opensim-SC-c5604d38573e6723e668073be6553ebfa7354a09.tar.bz2 opensim-SC-c5604d38573e6723e668073be6553ebfa7354a09.tar.xz |
similar to sps array in scenegraph
Diffstat (limited to 'OpenSim/Region')
-rwxr-xr-x | OpenSim/Region/Framework/Scenes/SceneGraph.cs | 29 |
1 files changed, 15 insertions, 14 deletions
diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs index 66a5325..51392ae 100755 --- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs +++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs | |||
@@ -43,9 +43,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
43 | public delegate void PhysicsCrash(); | 43 | public delegate void PhysicsCrash(); |
44 | 44 | ||
45 | public delegate void AttachToBackupDelegate(SceneObjectGroup sog); | 45 | public delegate void AttachToBackupDelegate(SceneObjectGroup sog); |
46 | |||
47 | public delegate void DetachFromBackupDelegate(SceneObjectGroup sog); | 46 | public delegate void DetachFromBackupDelegate(SceneObjectGroup sog); |
48 | |||
49 | public delegate void ChangedBackupDelegate(SceneObjectGroup sog); | 47 | public delegate void ChangedBackupDelegate(SceneObjectGroup sog); |
50 | 48 | ||
51 | /// <summary> | 49 | /// <summary> |
@@ -74,6 +72,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
74 | protected ConcurrentDictionary<UUID, ScenePresence> m_scenePresenceMap = new ConcurrentDictionary<UUID, ScenePresence>(); | 72 | protected ConcurrentDictionary<UUID, ScenePresence> m_scenePresenceMap = new ConcurrentDictionary<UUID, ScenePresence>(); |
75 | protected ConcurrentDictionary<uint, ScenePresence> m_scenePresenceLocalIDMap = new ConcurrentDictionary<uint, ScenePresence>(); | 73 | protected ConcurrentDictionary<uint, ScenePresence> m_scenePresenceLocalIDMap = new ConcurrentDictionary<uint, ScenePresence>(); |
76 | protected List<ScenePresence> m_scenePresenceArray = new List<ScenePresence>(); | 74 | protected List<ScenePresence> m_scenePresenceArray = new List<ScenePresence>(); |
75 | private int m_spArrayLastVersion; | ||
76 | private int m_spArrayVersion; | ||
77 | 77 | ||
78 | protected internal EntityManager Entities = new EntityManager(); | 78 | protected internal EntityManager Entities = new EntityManager(); |
79 | 79 | ||
@@ -121,6 +121,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
121 | { | 121 | { |
122 | m_scenePresencesLock = new System.Threading.ReaderWriterLockSlim(); | 122 | m_scenePresencesLock = new System.Threading.ReaderWriterLockSlim(); |
123 | m_parentScene = parent; | 123 | m_parentScene = parent; |
124 | m_spArrayLastVersion = 0; | ||
125 | m_spArrayVersion = 0; | ||
124 | } | 126 | } |
125 | 127 | ||
126 | public PhysicsScene PhysicsScene | 128 | public PhysicsScene PhysicsScene |
@@ -154,6 +156,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
154 | m_scenePresenceMap = new ConcurrentDictionary<UUID, ScenePresence>(); | 156 | m_scenePresenceMap = new ConcurrentDictionary<UUID, ScenePresence>(); |
155 | m_scenePresenceLocalIDMap = new ConcurrentDictionary<uint, ScenePresence>(); | 157 | m_scenePresenceLocalIDMap = new ConcurrentDictionary<uint, ScenePresence>(); |
156 | m_scenePresenceArray = new List<ScenePresence>(); | 158 | m_scenePresenceArray = new List<ScenePresence>(); |
159 | m_spArrayLastVersion = 0; | ||
160 | m_spArrayVersion = 0; | ||
157 | if (_PhyScene != null) | 161 | if (_PhyScene != null) |
158 | _PhyScene.OnPhysicsCrash -= physicsBasedCrash; | 162 | _PhyScene.OnPhysicsCrash -= physicsBasedCrash; |
159 | _PhyScene = null; | 163 | _PhyScene = null; |
@@ -709,13 +713,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
709 | 713 | ||
710 | m_numChildAgents++; | 714 | m_numChildAgents++; |
711 | 715 | ||
712 | List<ScenePresence> newlist = new List<ScenePresence>(m_scenePresenceArray); | ||
713 | |||
714 | if (!m_scenePresenceMap.ContainsKey(presence.UUID)) | 716 | if (!m_scenePresenceMap.ContainsKey(presence.UUID)) |
715 | { | 717 | { |
716 | m_scenePresenceMap[presence.UUID] = presence; | 718 | m_scenePresenceMap[presence.UUID] = presence; |
717 | m_scenePresenceLocalIDMap[presence.LocalId] = presence; | 719 | m_scenePresenceLocalIDMap[presence.LocalId] = presence; |
718 | newlist.Add(presence); | ||
719 | } | 720 | } |
720 | else | 721 | else |
721 | { | 722 | { |
@@ -724,8 +725,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
724 | uint oldLocalID = oldref.LocalId; | 725 | uint oldLocalID = oldref.LocalId; |
725 | // Replace the presence reference in the dictionary with the new value | 726 | // Replace the presence reference in the dictionary with the new value |
726 | m_scenePresenceMap[presence.UUID] = presence; | 727 | m_scenePresenceMap[presence.UUID] = presence; |
727 | newlist[newlist.IndexOf(oldref)] = presence; | ||
728 | |||
729 | if(presence.LocalId != oldLocalID) | 728 | if(presence.LocalId != oldLocalID) |
730 | { | 729 | { |
731 | m_scenePresenceLocalIDMap.TryRemove(oldLocalID, out oldref); | 730 | m_scenePresenceLocalIDMap.TryRemove(oldLocalID, out oldref); |
@@ -734,8 +733,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
734 | // Find the index in the list where the old ref was stored and update the reference | 733 | // Find the index in the list where the old ref was stored and update the reference |
735 | } | 734 | } |
736 | 735 | ||
737 | // Swap out the dictionary and list with new references | 736 | ++m_spArrayVersion; |
738 | m_scenePresenceArray = newlist; | ||
739 | } | 737 | } |
740 | finally | 738 | finally |
741 | { | 739 | { |
@@ -768,10 +766,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
768 | if(m_scenePresenceMap.TryRemove(agentID, out oldref)) | 766 | if(m_scenePresenceMap.TryRemove(agentID, out oldref)) |
769 | { | 767 | { |
770 | // Find the index in the list where the old ref was stored and remove the reference | 768 | // Find the index in the list where the old ref was stored and remove the reference |
771 | List<ScenePresence> newsps = new List<ScenePresence>(m_scenePresenceArray); | ||
772 | newsps.RemoveAt(newsps.IndexOf(oldref)); | ||
773 | m_scenePresenceArray = newsps; | ||
774 | m_scenePresenceLocalIDMap.TryRemove(oldref.LocalId, out oldref); | 769 | m_scenePresenceLocalIDMap.TryRemove(oldref.LocalId, out oldref); |
770 | ++m_spArrayVersion; | ||
775 | } | 771 | } |
776 | else | 772 | else |
777 | { | 773 | { |
@@ -911,8 +907,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
911 | bool entered = false; | 907 | bool entered = false; |
912 | try | 908 | try |
913 | { | 909 | { |
914 | m_scenePresencesLock.EnterReadLock(); | 910 | m_scenePresencesLock.EnterWriteLock(); |
915 | entered = true; | 911 | entered = true; |
912 | if(m_spArrayLastVersion != m_spArrayVersion) | ||
913 | { | ||
914 | m_scenePresenceArray = new List<ScenePresence>(m_scenePresenceMap.Values); | ||
915 | m_spArrayLastVersion = m_spArrayVersion; | ||
916 | } | ||
916 | return m_scenePresenceArray; | 917 | return m_scenePresenceArray; |
917 | } | 918 | } |
918 | catch | 919 | catch |
@@ -922,7 +923,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
922 | finally | 923 | finally |
923 | { | 924 | { |
924 | if(entered) | 925 | if(entered) |
925 | m_scenePresencesLock.ExitReadLock(); | 926 | m_scenePresencesLock.ExitWriteLock(); |
926 | } | 927 | } |
927 | } | 928 | } |
928 | 929 | ||