aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorAdam Frisby2007-04-22 18:51:03 +0000
committerAdam Frisby2007-04-22 18:51:03 +0000
commitd82466ec82ca1912bd72f668accb8456f4d37629 (patch)
treebfc9cb0f25f642561b63fbe407f4e5b6041ba991
parentNeeds testing. (diff)
downloadopensim-SC_OLD-d82466ec82ca1912bd72f668accb8456f4d37629.zip
opensim-SC_OLD-d82466ec82ca1912bd72f668accb8456f4d37629.tar.gz
opensim-SC_OLD-d82466ec82ca1912bd72f668accb8456f4d37629.tar.bz2
opensim-SC_OLD-d82466ec82ca1912bd72f668accb8456f4d37629.tar.xz
Added mutex instead of lock for update
-rw-r--r--OpenSim.RegionServer/world/World.cs74
1 files changed, 37 insertions, 37 deletions
diff --git a/OpenSim.RegionServer/world/World.cs b/OpenSim.RegionServer/world/World.cs
index b0392a6..e0f2e6f 100644
--- a/OpenSim.RegionServer/world/World.cs
+++ b/OpenSim.RegionServer/world/World.cs
@@ -5,6 +5,7 @@ using System.Collections.Generic;
5using System.Text; 5using System.Text;
6using System.Reflection; 6using System.Reflection;
7using System.IO; 7using System.IO;
8using System.Threading;
8using OpenSim.Physics.Manager; 9using OpenSim.Physics.Manager;
9using OpenSim.Framework.Interfaces; 10using OpenSim.Framework.Interfaces;
10using OpenSim.Framework.Assets; 11using OpenSim.Framework.Assets;
@@ -41,7 +42,7 @@ namespace OpenSim.world
41 private string m_regionName; 42 private string m_regionName;
42 private InventoryCache _inventoryCache; 43 private InventoryCache _inventoryCache;
43 private AssetCache _assetCache; 44 private AssetCache _assetCache;
44 private Object updateLock; 45 private Mutex updateLock;
45 46
46 /// <summary> 47 /// <summary>
47 /// Creates a new World class, and a region to go with it. 48 /// Creates a new World class, and a region to go with it.
@@ -53,7 +54,7 @@ namespace OpenSim.world
53 { 54 {
54 try 55 try
55 { 56 {
56 updateLock = null; 57 updateLock = new Mutex(false);
57 m_clientThreads = clientThreads; 58 m_clientThreads = clientThreads;
58 m_regionHandle = regionHandle; 59 m_regionHandle = regionHandle;
59 m_regionName = regionName; 60 m_regionName = regionName;
@@ -185,52 +186,51 @@ namespace OpenSim.world
185 /// </summary> 186 /// </summary>
186 public void Update() 187 public void Update()
187 { 188 {
188 lock (updateLock) 189 updateLock.WaitOne();
190 try
189 { 191 {
190 try 192 if (this.phyScene.IsThreaded)
191 { 193 {
192 if (this.phyScene.IsThreaded) 194 this.phyScene.GetResults();
193 {
194 this.phyScene.GetResults();
195 195
196 } 196 }
197 197
198 foreach (libsecondlife.LLUUID UUID in Entities.Keys) 198 foreach (libsecondlife.LLUUID UUID in Entities.Keys)
199 { 199 {
200 Entities[UUID].addForces(); 200 Entities[UUID].addForces();
201 } 201 }
202 202
203 lock (this.LockPhysicsEngine) 203 lock (this.LockPhysicsEngine)
204 { 204 {
205 this.phyScene.Simulate(timeStep); 205 this.phyScene.Simulate(timeStep);
206 } 206 }
207 207
208 foreach (libsecondlife.LLUUID UUID in Entities.Keys) 208 foreach (libsecondlife.LLUUID UUID in Entities.Keys)
209 { 209 {
210 Entities[UUID].update(); 210 Entities[UUID].update();
211 } 211 }
212 212
213 foreach (ScriptHandler scriptHandler in m_scriptHandlers.Values) 213 foreach (ScriptHandler scriptHandler in m_scriptHandlers.Values)
214 { 214 {
215 scriptHandler.OnFrame(); 215 scriptHandler.OnFrame();
216 } 216 }
217 foreach (IScriptEngine scripteng in this.scriptEngines.Values) 217 foreach (IScriptEngine scripteng in this.scriptEngines.Values)
218 { 218 {
219 scripteng.OnFrame(); 219 scripteng.OnFrame();
220 }
221 //backup world data
222 this.storageCount++;
223 if (storageCount > 1200) //set to how often you want to backup
224 {
225 this.Backup();
226 storageCount = 0;
227 }
228 } 220 }
229 catch (Exception e) 221 //backup world data
222 this.storageCount++;
223 if (storageCount > 1200) //set to how often you want to backup
230 { 224 {
231 OpenSim.Framework.Console.MainConsole.Instance.WriteLine("World.cs: Update() - Failed with exception " + e.ToString()); 225 this.Backup();
226 storageCount = 0;
232 } 227 }
233 } 228 }
229 catch (Exception e)
230 {
231 OpenSim.Framework.Console.MainConsole.Instance.WriteLine("World.cs: Update() - Failed with exception " + e.ToString());
232 }
233 updateLock.ReleaseMutex();
234 } 234 }
235 235
236 /// <summary> 236 /// <summary>