diff options
author | Tedd Hansen | 2007-08-19 10:28:27 +0000 |
---|---|---|
committer | Tedd Hansen | 2007-08-19 10:28:27 +0000 |
commit | e70cdbc5accc5025ed4e6262ff01ce50bf553141 (patch) | |
tree | b8b74de490ae4d8a03d63458f1ad06730a5e6635 /OpenSim/Region/ScriptEngine/DotNetEngine/AppDomainManager.cs | |
parent | Moved script loading from ScriptManager to AppDomainManager. Now increases sc... (diff) | |
download | opensim-SC_OLD-e70cdbc5accc5025ed4e6262ff01ce50bf553141.zip opensim-SC_OLD-e70cdbc5accc5025ed4e6262ff01ce50bf553141.tar.gz opensim-SC_OLD-e70cdbc5accc5025ed4e6262ff01ce50bf553141.tar.bz2 opensim-SC_OLD-e70cdbc5accc5025ed4e6262ff01ce50bf553141.tar.xz |
Added event method invoke cache to Executor. "Bind once, Invoke multiple times". Will speed up script event execution considerable. But at the cost of some memory (will be optimized later with RuntimeXHandle).
Diffstat (limited to 'OpenSim/Region/ScriptEngine/DotNetEngine/AppDomainManager.cs')
-rw-r--r-- | OpenSim/Region/ScriptEngine/DotNetEngine/AppDomainManager.cs | 51 |
1 files changed, 21 insertions, 30 deletions
diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/AppDomainManager.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/AppDomainManager.cs index 77c859f..1218b19 100644 --- a/OpenSim/Region/ScriptEngine/DotNetEngine/AppDomainManager.cs +++ b/OpenSim/Region/ScriptEngine/DotNetEngine/AppDomainManager.cs | |||
@@ -14,7 +14,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine | |||
14 | { | 14 | { |
15 | public class AppDomainManager | 15 | public class AppDomainManager |
16 | { | 16 | { |
17 | private int MaxScriptsPerAppDomain = 1; | 17 | private int MaxScriptsPerAppDomain = 3; |
18 | /// <summary> | 18 | /// <summary> |
19 | /// Internal list of all AppDomains | 19 | /// Internal list of all AppDomains |
20 | /// </summary> | 20 | /// </summary> |
@@ -22,7 +22,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine | |||
22 | /// <summary> | 22 | /// <summary> |
23 | /// Structure to keep track of data around AppDomain | 23 | /// Structure to keep track of data around AppDomain |
24 | /// </summary> | 24 | /// </summary> |
25 | private struct AppDomainStructure | 25 | private class AppDomainStructure |
26 | { | 26 | { |
27 | /// <summary> | 27 | /// <summary> |
28 | /// The AppDomain itself | 28 | /// The AppDomain itself |
@@ -57,33 +57,25 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine | |||
57 | /// <returns>Free AppDomain</returns> | 57 | /// <returns>Free AppDomain</returns> |
58 | private AppDomainStructure GetFreeAppDomain() | 58 | private AppDomainStructure GetFreeAppDomain() |
59 | { | 59 | { |
60 | FreeAppDomains(); | 60 | FreeAppDomains(); // Outsite lock, has its own GetLock |
61 | lock(GetLock) { | 61 | lock (GetLock) |
62 | { | ||
62 | // Current full? | 63 | // Current full? |
63 | if (CurrentAD.ScriptsLoaded >= MaxScriptsPerAppDomain) | 64 | if (CurrentAD != null && CurrentAD.ScriptsLoaded >= MaxScriptsPerAppDomain) |
64 | { | 65 | { |
65 | // Add it to AppDomains list and empty current | 66 | // Add it to AppDomains list and empty current |
66 | AppDomains.Add(CurrentAD); | 67 | AppDomains.Add(CurrentAD); |
67 | CurrentAD = new AppDomainStructure(); | 68 | CurrentAD = null; |
68 | } | 69 | } |
69 | // No current | 70 | // No current |
70 | if (CurrentAD.CurrentAppDomain == null) | 71 | if (CurrentAD == null) |
71 | { | 72 | { |
72 | // Create a new current AppDomain | 73 | // Create a new current AppDomain |
73 | CurrentAD = new AppDomainStructure(); | 74 | CurrentAD = new AppDomainStructure(); |
74 | CurrentAD.ScriptsWaitingUnload = 0; // to avoid compile warning for not in use | 75 | CurrentAD.CurrentAppDomain = PrepareNewAppDomain(); |
75 | CurrentAD.CurrentAppDomain = PrepareNewAppDomain(); | ||
76 | |||
77 | |||
78 | } | 76 | } |
79 | 77 | ||
80 | // Increase number of scripts loaded into this | 78 | Console.WriteLine("Scripts loaded in this Appdomain: " + CurrentAD.ScriptsLoaded); |
81 | // TODO: | ||
82 | // - We assume that every time someone wants an AppDomain they will load into it | ||
83 | // if this assumption is wrong we end up with a miscount and will never unload it. | ||
84 | // | ||
85 | |||
86 | // Return AppDomain | ||
87 | return CurrentAD; | 79 | return CurrentAD; |
88 | } // lock | 80 | } // lock |
89 | } | 81 | } |
@@ -143,19 +135,18 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine | |||
143 | 135 | ||
144 | 136 | ||
145 | 137 | ||
146 | public OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL.LSL_BaseClass LoadScript(string FileName, IScriptHost host) | 138 | public OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL.LSL_BaseClass LoadScript(string FileName) |
147 | { | 139 | { |
148 | //LSL_BaseClass mbrt = (LSL_BaseClass)FreeAppDomain.CreateInstanceAndUnwrap(FileName, "SecondLife.Script"); | 140 | // Find next available AppDomain to put it in |
149 | //Console.WriteLine("Base directory: " + AppDomain.CurrentDomain.BaseDirectory); | ||
150 | // * Find next available AppDomain to put it in | ||
151 | AppDomainStructure FreeAppDomain = GetFreeAppDomain(); | 141 | AppDomainStructure FreeAppDomain = GetFreeAppDomain(); |
152 | 142 | ||
153 | 143 | if (FreeAppDomain == null) Console.WriteLine("FreeAppDomain == null"); | |
144 | if (FreeAppDomain.CurrentAppDomain == null) Console.WriteLine("FreeAppDomain.CurrentAppDomain == null"); | ||
154 | LSL_BaseClass mbrt = (LSL_BaseClass)FreeAppDomain.CurrentAppDomain.CreateInstanceFromAndUnwrap(FileName, "SecondLife.Script"); | 145 | LSL_BaseClass mbrt = (LSL_BaseClass)FreeAppDomain.CurrentAppDomain.CreateInstanceFromAndUnwrap(FileName, "SecondLife.Script"); |
155 | //LSL_BuiltIn_Commands_Interface mbrt = (LSL_BuiltIn_Commands_Interface)FreeAppDomain.CreateInstanceFromAndUnwrap(FileName, "SecondLife.Script"); | ||
156 | //Type mytype = mbrt.GetType(); | 146 | //Type mytype = mbrt.GetType(); |
157 | //Console.WriteLine("is proxy={0}", RemotingServices.IsTransparentProxy(mbrt)); | 147 | Console.WriteLine("ScriptEngine AppDomainManager: is proxy={0}", RemotingServices.IsTransparentProxy(mbrt)); |
158 | 148 | ||
149 | // Increase script count in tihs AppDomain | ||
159 | FreeAppDomain.ScriptsLoaded++; | 150 | FreeAppDomain.ScriptsLoaded++; |
160 | 151 | ||
161 | //mbrt.Start(); | 152 | //mbrt.Start(); |
@@ -169,7 +160,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine | |||
169 | /// Increase "dead script" counter for an AppDomain | 160 | /// Increase "dead script" counter for an AppDomain |
170 | /// </summary> | 161 | /// </summary> |
171 | /// <param name="ad"></param> | 162 | /// <param name="ad"></param> |
172 | [Obsolete("Needs fixing!!!")] | 163 | [Obsolete("Needs fixing, needs a real purpose in life!!!")] |
173 | public void StopScript(AppDomain ad) | 164 | public void StopScript(AppDomain ad) |
174 | { | 165 | { |
175 | lock (FreeLock) | 166 | lock (FreeLock) |
@@ -188,10 +179,10 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine | |||
188 | if (ads.CurrentAppDomain == ad) | 179 | if (ads.CurrentAppDomain == ad) |
189 | { | 180 | { |
190 | // Found it - messy code to increase structure | 181 | // Found it - messy code to increase structure |
191 | AppDomainStructure ads2 = ads; | 182 | //AppDomainStructure ads2 = ads; |
192 | ads2.ScriptsWaitingUnload++; | 183 | ads.ScriptsWaitingUnload++; |
193 | AppDomains.Remove(ads); | 184 | //AppDomains.Remove(ads); |
194 | AppDomains.Add(ads2); | 185 | //AppDomains.Add(ads2); |
195 | return; | 186 | return; |
196 | } | 187 | } |
197 | } // foreach | 188 | } // foreach |