aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Framework')
-rw-r--r--OpenSim/Framework/Console/ConsoleUtil.cs114
-rw-r--r--OpenSim/Framework/GridInstantMessage.cs9
-rw-r--r--OpenSim/Framework/Monitoring/SimExtraStatsCollector.cs13
-rw-r--r--OpenSim/Framework/Monitoring/StatsManager.cs145
-rw-r--r--OpenSim/Framework/PacketPool.cs247
-rw-r--r--OpenSim/Framework/Util.cs13
6 files changed, 288 insertions, 253 deletions
diff --git a/OpenSim/Framework/Console/ConsoleUtil.cs b/OpenSim/Framework/Console/ConsoleUtil.cs
new file mode 100644
index 0000000..2612a50
--- /dev/null
+++ b/OpenSim/Framework/Console/ConsoleUtil.cs
@@ -0,0 +1,114 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections.Generic;
30using System.Linq;
31using System.Reflection;
32using log4net;
33using OpenMetaverse;
34
35public class ConsoleUtil
36{
37 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
38
39 public const string MinRawConsoleVectorValue = "-~";
40 public const string MaxRawConsoleVectorValue = "~";
41
42 public const string VectorSeparator = ",";
43 public static char[] VectorSeparatorChars = VectorSeparator.ToCharArray();
44
45 /// <summary>
46 /// Convert a minimum vector input from the console to an OpenMetaverse.Vector3
47 /// </summary>
48 /// <param name='rawConsoleVector'>/param>
49 /// <param name='vector'></param>
50 /// <returns></returns>
51 public static bool TryParseConsoleMinVector(string rawConsoleVector, out Vector3 vector)
52 {
53 return TryParseConsoleVector(rawConsoleVector, c => float.MinValue.ToString(), out vector);
54 }
55
56 /// <summary>
57 /// Convert a maximum vector input from the console to an OpenMetaverse.Vector3
58 /// </summary>
59 /// <param name='rawConsoleVector'>/param>
60 /// <param name='vector'></param>
61 /// <returns></returns>
62 public static bool TryParseConsoleMaxVector(string rawConsoleVector, out Vector3 vector)
63 {
64 return TryParseConsoleVector(rawConsoleVector, c => float.MaxValue.ToString(), out vector);
65 }
66
67 /// <summary>
68 /// Convert a vector input from the console to an OpenMetaverse.Vector3
69 /// </summary>
70 /// <param name='rawConsoleVector'>
71 /// A string in the form <x>,<y>,<z> where there is no space between values.
72 /// Any component can be missing (e.g. ,,40). blankComponentFunc is invoked to replace the blank with a suitable value
73 /// Also, if the blank component is at the end, then the comma can be missed off entirely (e.g. 40,30 or 40)
74 /// The strings "~" and "-~" are valid in components. The first substitutes float.MaxValue whilst the second is float.MinValue
75 /// Other than that, component values must be numeric.
76 /// </param>
77 /// <param name='blankComponentFunc'></param>
78 /// <param name='vector'></param>
79 /// <returns></returns>
80 public static bool TryParseConsoleVector(
81 string rawConsoleVector, Func<string, string> blankComponentFunc, out Vector3 vector)
82 {
83 List<string> components = rawConsoleVector.Split(VectorSeparatorChars).ToList();
84
85 if (components.Count < 1 || components.Count > 3)
86 {
87 vector = Vector3.Zero;
88 return false;
89 }
90
91 for (int i = components.Count; i < 3; i++)
92 components.Add("");
93
94 List<string> semiDigestedComponents
95 = components.ConvertAll<string>(
96 c =>
97 {
98 if (c == "")
99 return blankComponentFunc.Invoke(c);
100 else if (c == MaxRawConsoleVectorValue)
101 return float.MaxValue.ToString();
102 else if (c == MinRawConsoleVectorValue)
103 return float.MinValue.ToString();
104 else
105 return c;
106 });
107
108 string semiDigestedConsoleVector = string.Join(VectorSeparator, semiDigestedComponents.ToArray());
109
110 m_log.DebugFormat("[CONSOLE UTIL]: Parsing {0} into OpenMetaverse.Vector3", semiDigestedConsoleVector);
111
112 return Vector3.TryParse(semiDigestedConsoleVector, out vector);
113 }
114} \ No newline at end of file
diff --git a/OpenSim/Framework/GridInstantMessage.cs b/OpenSim/Framework/GridInstantMessage.cs
index a6bf6e3..6ae0488 100644
--- a/OpenSim/Framework/GridInstantMessage.cs
+++ b/OpenSim/Framework/GridInstantMessage.cs
@@ -44,7 +44,6 @@ namespace OpenSim.Framework
44 public Vector3 Position; 44 public Vector3 Position;
45 public byte[] binaryBucket; 45 public byte[] binaryBucket;
46 46
47
48 public uint ParentEstateID; 47 public uint ParentEstateID;
49 public Guid RegionID; 48 public Guid RegionID;
50 public uint timestamp; 49 public uint timestamp;
@@ -58,7 +57,7 @@ namespace OpenSim.Framework
58 string _fromAgentName, UUID _toAgentID, 57 string _fromAgentName, UUID _toAgentID,
59 byte _dialog, bool _fromGroup, string _message, 58 byte _dialog, bool _fromGroup, string _message,
60 UUID _imSessionID, bool _offline, Vector3 _position, 59 UUID _imSessionID, bool _offline, Vector3 _position,
61 byte[] _binaryBucket) 60 byte[] _binaryBucket, bool addTimestamp)
62 { 61 {
63 fromAgentID = _fromAgentID.Guid; 62 fromAgentID = _fromAgentID.Guid;
64 fromAgentName = _fromAgentName; 63 fromAgentName = _fromAgentName;
@@ -79,7 +78,9 @@ namespace OpenSim.Framework
79 ParentEstateID = scene.RegionInfo.EstateSettings.ParentEstateID; 78 ParentEstateID = scene.RegionInfo.EstateSettings.ParentEstateID;
80 RegionID = scene.RegionInfo.RegionSettings.RegionUUID.Guid; 79 RegionID = scene.RegionInfo.RegionSettings.RegionUUID.Guid;
81 } 80 }
82 timestamp = (uint)Util.UnixTimeSinceEpoch(); 81
82 if (addTimestamp)
83 timestamp = (uint)Util.UnixTimeSinceEpoch();
83 } 84 }
84 85
85 public GridInstantMessage(IScene scene, UUID _fromAgentID, 86 public GridInstantMessage(IScene scene, UUID _fromAgentID,
@@ -87,7 +88,7 @@ namespace OpenSim.Framework
87 string _message, bool _offline, 88 string _message, bool _offline,
88 Vector3 _position) : this(scene, _fromAgentID, _fromAgentName, 89 Vector3 _position) : this(scene, _fromAgentID, _fromAgentName,
89 _toAgentID, _dialog, false, _message, 90 _toAgentID, _dialog, false, _message,
90 _fromAgentID ^ _toAgentID, _offline, _position, new byte[0]) 91 _fromAgentID ^ _toAgentID, _offline, _position, new byte[0], true)
91 { 92 {
92 } 93 }
93 } 94 }
diff --git a/OpenSim/Framework/Monitoring/SimExtraStatsCollector.cs b/OpenSim/Framework/Monitoring/SimExtraStatsCollector.cs
index cdd7cc7..8ac9090 100644
--- a/OpenSim/Framework/Monitoring/SimExtraStatsCollector.cs
+++ b/OpenSim/Framework/Monitoring/SimExtraStatsCollector.cs
@@ -355,10 +355,19 @@ Asset service request failures: {3}" + Environment.NewLine,
355 sb.Append(Environment.NewLine); 355 sb.Append(Environment.NewLine);
356 sb.Append( 356 sb.Append(
357 string.Format( 357 string.Format(
358 "{0,6:0} {1,6:0} {2,6:0} {3,6:0} {4,6:0} {5,6:0.0} {6,6:0.0} {7,6:0.0} {8,6:0.0} {9,6:0.0} {10,6:0.0}", 358 "{0,6:0} {1,6:0} {2,6:0} {3,6:0} {4,6:0} {5,6:0.0} {6,6:0.0} {7,6:0.0} {8,6:0.0} {9,6:0.0} {10,6:0.0}\n\n",
359 inPacketsPerSecond, outPacketsPerSecond, pendingDownloads, pendingUploads, unackedBytes, totalFrameTime, 359 inPacketsPerSecond, outPacketsPerSecond, pendingDownloads, pendingUploads, unackedBytes, totalFrameTime,
360 netFrameTime, physicsFrameTime, otherFrameTime, agentFrameTime, imageFrameTime)); 360 netFrameTime, physicsFrameTime, otherFrameTime, agentFrameTime, imageFrameTime));
361 sb.Append(Environment.NewLine); 361
362 foreach (KeyValuePair<string, Stat> kvp in StatsManager.RegisteredStats)
363 {
364 Stat stat = kvp.Value;
365
366 if (stat.Category == "scene" && stat.Verbosity == StatVerbosity.Info)
367 {
368 sb.AppendFormat("Slow frames ({0}): {1}\n", stat.Container, stat.Value);
369 }
370 }
362 371
363 /* 372 /*
364 sb.Append(Environment.NewLine); 373 sb.Append(Environment.NewLine);
diff --git a/OpenSim/Framework/Monitoring/StatsManager.cs b/OpenSim/Framework/Monitoring/StatsManager.cs
index d78fa6a..b5dc24f 100644
--- a/OpenSim/Framework/Monitoring/StatsManager.cs
+++ b/OpenSim/Framework/Monitoring/StatsManager.cs
@@ -25,6 +25,9 @@
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */ 26 */
27 27
28using System;
29using System.Collections.Generic;
30
28namespace OpenSim.Framework.Monitoring 31namespace OpenSim.Framework.Monitoring
29{ 32{
30 /// <summary> 33 /// <summary>
@@ -32,6 +35,14 @@ namespace OpenSim.Framework.Monitoring
32 /// </summary> 35 /// </summary>
33 public class StatsManager 36 public class StatsManager
34 { 37 {
38 /// <summary>
39 /// Registered stats.
40 /// </summary>
41 /// <remarks>
42 /// Do not add or remove from this dictionary.
43 /// </remarks>
44 public static Dictionary<string, Stat> RegisteredStats = new Dictionary<string, Stat>();
45
35 private static AssetStatsCollector assetStats; 46 private static AssetStatsCollector assetStats;
36 private static UserStatsCollector userStats; 47 private static UserStatsCollector userStats;
37 private static SimExtraStatsCollector simExtraStats = new SimExtraStatsCollector(); 48 private static SimExtraStatsCollector simExtraStats = new SimExtraStatsCollector();
@@ -61,5 +72,139 @@ namespace OpenSim.Framework.Monitoring
61 72
62 return userStats; 73 return userStats;
63 } 74 }
75
76 public static bool RegisterStat(Stat stat)
77 {
78 lock (RegisteredStats)
79 {
80 if (RegisteredStats.ContainsKey(stat.UniqueName))
81 {
82 // XXX: For now just return false. This is to avoid problems in regression tests where all tests
83 // in a class are run in the same instance of the VM.
84 return false;
85
86// throw new Exception(
87// "StatsManager already contains stat with ShortName {0} in Category {1}", stat.ShortName, stat.Category);
88 }
89
90 // We take a replace-on-write approach here so that we don't need to generate a new Dictionary
91 Dictionary<string, Stat> newRegisteredStats = new Dictionary<string, Stat>(RegisteredStats);
92 newRegisteredStats[stat.UniqueName] = stat;
93 RegisteredStats = newRegisteredStats;
94 }
95
96 return true;
97 }
98
99 public static bool DeregisterStat(Stat stat)
100 {
101 lock (RegisteredStats)
102 {
103 if (!RegisteredStats.ContainsKey(stat.UniqueName))
104 return false;
105
106 Dictionary<string, Stat> newRegisteredStats = new Dictionary<string, Stat>(RegisteredStats);
107 newRegisteredStats.Remove(stat.UniqueName);
108 RegisteredStats = newRegisteredStats;
109
110 return true;
111 }
112 }
113 }
114
115 /// <summary>
116 /// Verbosity of stat.
117 /// </summary>
118 /// <remarks>
119 /// Info will always be displayed.
120 /// </remarks>
121 public enum StatVerbosity
122 {
123 Debug,
124 Info
125 }
126
127 /// <summary>
128 /// Holds individual static details
129 /// </summary>
130 public class Stat
131 {
132 /// <summary>
133 /// Unique stat name used for indexing. Each ShortName in a Category must be unique.
134 /// </summary>
135 public string UniqueName { get; private set; }
136
137 /// <summary>
138 /// Category of this stat (e.g. cache, scene, etc).
139 /// </summary>
140 public string Category { get; private set; }
141
142 /// <summary>
143 /// Containing name for this stat.
144 /// FIXME: In the case of a scene, this is currently the scene name (though this leaves
145 /// us with a to-be-resolved problem of non-unique region names).
146 /// </summary>
147 /// <value>
148 /// The container.
149 /// </value>
150 public string Container { get; private set; }
151
152 public StatVerbosity Verbosity { get; private set; }
153 public string ShortName { get; private set; }
154 public string Name { get; private set; }
155 public string Description { get; private set; }
156 public virtual string UnitName { get; private set; }
157
158 public virtual double Value { get; set; }
159
160 public Stat(
161 string shortName, string name, string unitName, string category, string container, StatVerbosity verbosity, string description)
162 {
163 ShortName = shortName;
164 Name = name;
165 UnitName = unitName;
166 Category = category;
167 Container = container;
168 Verbosity = verbosity;
169 Description = description;
170
171 UniqueName = GenUniqueName(Container, Category, ShortName);
172 }
173
174 public static string GenUniqueName(string container, string category, string shortName)
175 {
176 return string.Format("{0}+{1}+{2}", container, category, shortName);
177 }
178 }
179
180 public class PercentageStat : Stat
181 {
182 public int Antecedent { get; set; }
183 public int Consequent { get; set; }
184
185 public override double Value
186 {
187 get
188 {
189 int c = Consequent;
190
191 // Avoid any chance of a multi-threaded divide-by-zero
192 if (c == 0)
193 return 0;
194
195 return (double)Antecedent / c;
196 }
197
198 set
199 {
200 throw new Exception("Cannot set value on a PercentageStat");
201 }
202 }
203
204 public PercentageStat(
205 string shortName, string name, string category, string container, StatVerbosity verbosity, string description)
206 : base(shortName, name, " %", category, container, verbosity, description)
207 {
208 }
64 } 209 }
65} \ No newline at end of file 210} \ No newline at end of file
diff --git a/OpenSim/Framework/PacketPool.cs b/OpenSim/Framework/PacketPool.cs
deleted file mode 100644
index 41d17c5..0000000
--- a/OpenSim/Framework/PacketPool.cs
+++ /dev/null
@@ -1,247 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections.Generic;
30using System.Reflection;
31using OpenMetaverse;
32using OpenMetaverse.Packets;
33using log4net;
34
35namespace OpenSim.Framework
36{
37
38 public sealed class PacketPool
39 {
40 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
41
42 private static readonly PacketPool instance = new PacketPool();
43
44 private bool packetPoolEnabled = true;
45 private bool dataBlockPoolEnabled = true;
46
47 private readonly Dictionary<PacketType, Stack<Packet>> pool = new Dictionary<PacketType, Stack<Packet>>();
48
49 private static Dictionary<Type, Stack<Object>> DataBlocks =
50 new Dictionary<Type, Stack<Object>>();
51
52 static PacketPool()
53 {
54 }
55
56 public static PacketPool Instance
57 {
58 get { return instance; }
59 }
60
61 public bool RecyclePackets
62 {
63 set { packetPoolEnabled = value; }
64 get { return packetPoolEnabled; }
65 }
66
67 public bool RecycleDataBlocks
68 {
69 set { dataBlockPoolEnabled = value; }
70 get { return dataBlockPoolEnabled; }
71 }
72
73 public Packet GetPacket(PacketType type)
74 {
75 Packet packet;
76
77 if (!packetPoolEnabled)
78 return Packet.BuildPacket(type);
79
80 lock (pool)
81 {
82 if (!pool.ContainsKey(type) || pool[type] == null || (pool[type]).Count == 0)
83 {
84 // Creating a new packet if we cannot reuse an old package
85 packet = Packet.BuildPacket(type);
86 }
87 else
88 {
89 // Recycle old packages
90 packet = (pool[type]).Pop();
91 }
92 }
93
94 return packet;
95 }
96
97 // private byte[] decoded_header = new byte[10];
98 private static PacketType GetType(byte[] bytes)
99 {
100 byte[] decoded_header = new byte[10 + 8];
101 ushort id;
102 PacketFrequency freq;
103
104 if ((bytes[0] & Helpers.MSG_ZEROCODED) != 0)
105 {
106 Helpers.ZeroDecode(bytes, 16, decoded_header);
107 }
108 else
109 {
110 Buffer.BlockCopy(bytes, 0, decoded_header, 0, 10);
111 }
112
113 if (decoded_header[6] == 0xFF)
114 {
115 if (decoded_header[7] == 0xFF)
116 {
117 id = (ushort) ((decoded_header[8] << 8) + decoded_header[9]);
118 freq = PacketFrequency.Low;
119 }
120 else
121 {
122 id = decoded_header[7];
123 freq = PacketFrequency.Medium;
124 }
125 }
126 else
127 {
128 id = decoded_header[6];
129 freq = PacketFrequency.High;
130 }
131
132 return Packet.GetType(id, freq);
133 }
134
135 public Packet GetPacket(byte[] bytes, ref int packetEnd, byte[] zeroBuffer)
136 {
137 PacketType type = GetType(bytes);
138
139 Array.Clear(zeroBuffer, 0, zeroBuffer.Length);
140
141 int i = 0;
142 Packet packet = GetPacket(type);
143 if (packet == null)
144 m_log.WarnFormat("[PACKETPOOL]: Failed to get packet of type {0}", type);
145 else
146 packet.FromBytes(bytes, ref i, ref packetEnd, zeroBuffer);
147
148 return packet;
149 }
150
151 /// <summary>
152 /// Return a packet to the packet pool
153 /// </summary>
154 /// <param name="packet"></param>
155 public void ReturnPacket(Packet packet)
156 {
157 if (dataBlockPoolEnabled)
158 {
159 switch (packet.Type)
160 {
161 case PacketType.ObjectUpdate:
162 ObjectUpdatePacket oup = (ObjectUpdatePacket)packet;
163
164 foreach (ObjectUpdatePacket.ObjectDataBlock oupod in oup.ObjectData)
165 ReturnDataBlock<ObjectUpdatePacket.ObjectDataBlock>(oupod);
166
167 oup.ObjectData = null;
168 break;
169
170 case PacketType.ImprovedTerseObjectUpdate:
171 ImprovedTerseObjectUpdatePacket itoup = (ImprovedTerseObjectUpdatePacket)packet;
172
173 foreach (ImprovedTerseObjectUpdatePacket.ObjectDataBlock itoupod in itoup.ObjectData)
174 ReturnDataBlock<ImprovedTerseObjectUpdatePacket.ObjectDataBlock>(itoupod);
175
176 itoup.ObjectData = null;
177 break;
178 }
179 }
180
181 if (packetPoolEnabled)
182 {
183 switch (packet.Type)
184 {
185 // List pooling packets here
186 case PacketType.PacketAck:
187 case PacketType.ObjectUpdate:
188 case PacketType.ImprovedTerseObjectUpdate:
189 lock (pool)
190 {
191 PacketType type = packet.Type;
192
193 if (!pool.ContainsKey(type))
194 {
195 pool[type] = new Stack<Packet>();
196 }
197
198 if ((pool[type]).Count < 50)
199 {
200 (pool[type]).Push(packet);
201 }
202 }
203 break;
204
205 // Other packets wont pool
206 default:
207 return;
208 }
209 }
210 }
211
212 public static T GetDataBlock<T>() where T: new()
213 {
214 lock (DataBlocks)
215 {
216 Stack<Object> s;
217
218 if (DataBlocks.TryGetValue(typeof(T), out s))
219 {
220 if (s.Count > 0)
221 return (T)s.Pop();
222 }
223 else
224 {
225 DataBlocks[typeof(T)] = new Stack<Object>();
226 }
227
228 return new T();
229 }
230 }
231
232 public static void ReturnDataBlock<T>(T block) where T: new()
233 {
234 if (block == null)
235 return;
236
237 lock (DataBlocks)
238 {
239 if (!DataBlocks.ContainsKey(typeof(T)))
240 DataBlocks[typeof(T)] = new Stack<Object>();
241
242 if (DataBlocks[typeof(T)].Count < 50)
243 DataBlocks[typeof(T)].Push(block);
244 }
245 }
246 }
247}
diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs
index 1b9777f..5c7797a 100644
--- a/OpenSim/Framework/Util.cs
+++ b/OpenSim/Framework/Util.cs
@@ -534,6 +534,19 @@ namespace OpenSim.Framework
534 } 534 }
535 535
536 /// <summary> 536 /// <summary>
537 /// Determines whether a point is inside a bounding box.
538 /// </summary>
539 /// <param name='v'>/param>
540 /// <param name='min'></param>
541 /// <param name='max'></param>
542 /// <returns></returns>
543 public static bool IsInsideBox(Vector3 v, Vector3 min, Vector3 max)
544 {
545 return v.X >= min.X & v.Y >= min.Y && v.Z >= min.Z
546 && v.X <= max.X && v.Y <= max.Y && v.Z <= max.Z;
547 }
548
549 /// <summary>
537 /// Are the co-ordinates of the new region visible from the old region? 550 /// Are the co-ordinates of the new region visible from the old region?
538 /// </summary> 551 /// </summary>
539 /// <param name="oldx">Old region x-coord</param> 552 /// <param name="oldx">Old region x-coord</param>