From 67e12b95ea7b68f4904a7484d77ecfd787d16d0c Mon Sep 17 00:00:00 2001 From: lbsa71 Date: Tue, 30 Oct 2007 09:05:31 +0000 Subject: * Optimized usings * Shortened type references * Removed redundant 'this' qualifier --- .../ScriptEngine/DotNetEngine/AppDomainManager.cs | 48 +++++++++++----------- 1 file changed, 23 insertions(+), 25 deletions(-) (limited to 'OpenSim/Grid/ScriptEngine/DotNetEngine/AppDomainManager.cs') diff --git a/OpenSim/Grid/ScriptEngine/DotNetEngine/AppDomainManager.cs b/OpenSim/Grid/ScriptEngine/DotNetEngine/AppDomainManager.cs index e5478ae..e6c1678 100644 --- a/OpenSim/Grid/ScriptEngine/DotNetEngine/AppDomainManager.cs +++ b/OpenSim/Grid/ScriptEngine/DotNetEngine/AppDomainManager.cs @@ -27,27 +27,22 @@ */ using System; +using System.Collections; using System.Collections.Generic; -using System.Text; using System.Reflection; -using System.Threading; -using System.Runtime.Remoting; -using System.IO; -using OpenSim.Region.Environment.Scenes; -using OpenSim.Region.Environment.Scenes.Scripting; using OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSL; -using OpenSim.Region.ScriptEngine.Common; -using libsecondlife; namespace OpenSim.Grid.ScriptEngine.DotNetEngine { public class AppDomainManager { private int maxScriptsPerAppDomain = 1; + /// /// Internal list of all AppDomains /// private List appDomains = new List(); + /// /// Structure to keep track of data around AppDomain /// @@ -57,19 +52,23 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine /// The AppDomain itself /// public AppDomain CurrentAppDomain; + /// /// Number of scripts loaded into AppDomain /// public int ScriptsLoaded; + /// /// Number of dead scripts /// public int ScriptsWaitingUnload; } + /// /// Current AppDomain /// private AppDomainStructure currentAD; + private object getLock = new object(); // Mutex private object freeLock = new object(); // Mutex @@ -94,22 +93,23 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine { // Add it to AppDomains list and empty current appDomains.Add(currentAD); - currentAD = null; + currentAD = null; } // No current if (currentAD == null) { // Create a new current AppDomain currentAD = new AppDomainStructure(); - currentAD.CurrentAppDomain = PrepareNewAppDomain(); + currentAD.CurrentAppDomain = PrepareNewAppDomain(); } - Console.WriteLine("Scripts loaded in this Appdomain: " + currentAD.ScriptsLoaded); + Console.WriteLine("Scripts loaded in this Appdomain: " + currentAD.ScriptsLoaded); return currentAD; } // lock } private int AppDomainNameCount; + /// /// Create and prepare a new AppDomain for scripts /// @@ -130,12 +130,12 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine ads.ConfigurationFile = AppDomain.CurrentDomain.SetupInformation.ConfigurationFile; AppDomain AD = AppDomain.CreateDomain("ScriptAppDomain_" + AppDomainNameCount, null, ads); - Console.WriteLine("Loading: " + AssemblyName.GetAssemblyName("OpenSim.Region.ScriptEngine.Common.dll").ToString()); + Console.WriteLine("Loading: " + + AssemblyName.GetAssemblyName("OpenSim.Region.ScriptEngine.Common.dll").ToString()); AD.Load(AssemblyName.GetAssemblyName("OpenSim.Region.ScriptEngine.Common.dll")); // Return the new AppDomain return AD; - } /// @@ -146,7 +146,7 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine lock (freeLock) { // Go through all - foreach (AppDomainStructure ads in new System.Collections.ArrayList(appDomains)) + foreach (AppDomainStructure ads in new ArrayList(appDomains)) { // Don't process current AppDomain if (ads.CurrentAppDomain != currentAD.CurrentAppDomain) @@ -164,23 +164,25 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine // Unload AppDomain.Unload(ads.CurrentAppDomain); #if DEBUG - Console.WriteLine("AppDomain unload freed " + (m - GC.GetTotalMemory(true)) + " bytes of memory"); + Console.WriteLine("AppDomain unload freed " + (m - GC.GetTotalMemory(true)) + + " bytes of memory"); #endif } } } // foreach } // lock } - - public OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSL.LSL_BaseClass LoadScript(string FileName) + public LSL_BaseClass LoadScript(string FileName) { // Find next available AppDomain to put it in AppDomainStructure FreeAppDomain = GetFreeAppDomain(); - + Console.WriteLine("Loading into AppDomain: " + FileName); - LSL_BaseClass mbrt = (LSL_BaseClass)FreeAppDomain.CurrentAppDomain.CreateInstanceFromAndUnwrap(FileName, "SecondLife.Script"); + LSL_BaseClass mbrt = + (LSL_BaseClass) + FreeAppDomain.CurrentAppDomain.CreateInstanceFromAndUnwrap(FileName, "SecondLife.Script"); //Console.WriteLine("ScriptEngine AppDomainManager: is proxy={0}", RemotingServices.IsTransparentProxy(mbrt)); FreeAppDomain.ScriptsLoaded++; @@ -207,7 +209,7 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine } // Lopp through all AppDomains - foreach (AppDomainStructure ads in new System.Collections.ArrayList(appDomains)) + foreach (AppDomainStructure ads in new ArrayList(appDomains)) { if (ads.CurrentAppDomain == ad) { @@ -219,10 +221,6 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine } // lock UnloadAppDomains(); // Outsite lock, has its own GetLock - - } - - } -} +} \ No newline at end of file -- cgit v1.1