From d82466ec82ca1912bd72f668accb8456f4d37629 Mon Sep 17 00:00:00 2001
From: Adam Frisby
Date: Sun, 22 Apr 2007 18:51:03 +0000
Subject: Added mutex instead of lock for update
---
OpenSim.RegionServer/world/World.cs | 74 ++++++++++++++++++-------------------
1 file changed, 37 insertions(+), 37 deletions(-)
(limited to 'OpenSim.RegionServer/world')
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;
using System.Text;
using System.Reflection;
using System.IO;
+using System.Threading;
using OpenSim.Physics.Manager;
using OpenSim.Framework.Interfaces;
using OpenSim.Framework.Assets;
@@ -41,7 +42,7 @@ namespace OpenSim.world
private string m_regionName;
private InventoryCache _inventoryCache;
private AssetCache _assetCache;
- private Object updateLock;
+ private Mutex updateLock;
///
/// Creates a new World class, and a region to go with it.
@@ -53,7 +54,7 @@ namespace OpenSim.world
{
try
{
- updateLock = null;
+ updateLock = new Mutex(false);
m_clientThreads = clientThreads;
m_regionHandle = regionHandle;
m_regionName = regionName;
@@ -185,52 +186,51 @@ namespace OpenSim.world
///
public void Update()
{
- lock (updateLock)
+ updateLock.WaitOne();
+ try
{
- try
+ if (this.phyScene.IsThreaded)
{
- if (this.phyScene.IsThreaded)
- {
- this.phyScene.GetResults();
+ this.phyScene.GetResults();
- }
+ }
- foreach (libsecondlife.LLUUID UUID in Entities.Keys)
- {
- Entities[UUID].addForces();
- }
+ foreach (libsecondlife.LLUUID UUID in Entities.Keys)
+ {
+ Entities[UUID].addForces();
+ }
- lock (this.LockPhysicsEngine)
- {
- this.phyScene.Simulate(timeStep);
- }
+ lock (this.LockPhysicsEngine)
+ {
+ this.phyScene.Simulate(timeStep);
+ }
- foreach (libsecondlife.LLUUID UUID in Entities.Keys)
- {
- Entities[UUID].update();
- }
+ foreach (libsecondlife.LLUUID UUID in Entities.Keys)
+ {
+ Entities[UUID].update();
+ }
- foreach (ScriptHandler scriptHandler in m_scriptHandlers.Values)
- {
- scriptHandler.OnFrame();
- }
- foreach (IScriptEngine scripteng in this.scriptEngines.Values)
- {
- scripteng.OnFrame();
- }
- //backup world data
- this.storageCount++;
- if (storageCount > 1200) //set to how often you want to backup
- {
- this.Backup();
- storageCount = 0;
- }
+ foreach (ScriptHandler scriptHandler in m_scriptHandlers.Values)
+ {
+ scriptHandler.OnFrame();
+ }
+ foreach (IScriptEngine scripteng in this.scriptEngines.Values)
+ {
+ scripteng.OnFrame();
}
- catch (Exception e)
+ //backup world data
+ this.storageCount++;
+ if (storageCount > 1200) //set to how often you want to backup
{
- OpenSim.Framework.Console.MainConsole.Instance.WriteLine("World.cs: Update() - Failed with exception " + e.ToString());
+ this.Backup();
+ storageCount = 0;
}
}
+ catch (Exception e)
+ {
+ OpenSim.Framework.Console.MainConsole.Instance.WriteLine("World.cs: Update() - Failed with exception " + e.ToString());
+ }
+ updateLock.ReleaseMutex();
}
///
--
cgit v1.1