mirror of
https://github.com/opensim/opensim.git
synced 2026-08-08 18:25:33 +08:00
cosmetics
This commit is contained in:
@@ -26,7 +26,7 @@
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Threading;
|
||||
using log4net;
|
||||
|
||||
@@ -86,6 +86,7 @@ namespace OpenSim.Framework.Monitoring
|
||||
Watchdog.Stop();
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Thread StartThread(ThreadStart start, string name, bool alarmIfTimeout = false, bool log = true)
|
||||
{
|
||||
return StartThread(start, name, ThreadPriority.Normal, true, alarmIfTimeout, null, Watchdog.DEFAULT_WATCHDOG_TIMEOUT_MS, log);
|
||||
@@ -101,6 +102,7 @@ namespace OpenSim.Framework.Monitoring
|
||||
/// <param name="alarmIfTimeout">Trigger an alarm function is we have timed out</param>
|
||||
/// <param name="log">If true then creation of thread is logged.</param>
|
||||
/// <returns>The newly created Thread object</returns>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Thread StartThread(
|
||||
ThreadStart start, string name, ThreadPriority priority, bool alarmIfTimeout, bool log = true)
|
||||
{
|
||||
@@ -245,11 +247,18 @@ namespace OpenSim.Framework.Monitoring
|
||||
/// <param name="callback"></param>
|
||||
/// <param name="obj"></param>
|
||||
/// <param name="name">The name of the job. This is used in monitoring and debugging.</param>
|
||||
public static void RunInThreadPool(System.Threading.WaitCallback callback, object obj, string name, bool timeout = true)
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static void RunInThreadPool(WaitCallback callback, object obj, string name, bool timeout = true)
|
||||
{
|
||||
Util.FireAndForget(callback, obj, name, timeout);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static void RunInThreadPool(WaitCallback callback, string name, bool timeout = true)
|
||||
{
|
||||
Util.FireAndForget(callback, null, name, timeout);
|
||||
}
|
||||
|
||||
private static void HandleControlCommand(string module, string[] args)
|
||||
{
|
||||
// if (SceneManager.Instance.CurrentScene != null && SceneManager.Instance.CurrentScene != m_udpServer.Scene)
|
||||
|
||||
@@ -248,13 +248,13 @@ namespace OpenSim.Framework
|
||||
public static Encoding UTF8 = Encoding.UTF8;
|
||||
public static Encoding UTF8NoBomEncoding = new UTF8Encoding(false);
|
||||
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static byte[] UTF8Getbytes(string s)
|
||||
{
|
||||
return UTF8.GetBytes(s);
|
||||
}
|
||||
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static byte[] UTF8NBGetbytes(string s)
|
||||
{
|
||||
return UTF8NoBomEncoding.GetBytes(s);
|
||||
@@ -388,7 +388,7 @@ namespace OpenSim.Framework
|
||||
get { return randomClass; }
|
||||
}
|
||||
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static ulong UIntsToLong(uint X, uint Y)
|
||||
{
|
||||
return ((ulong)X << 32) | (ulong)Y;
|
||||
@@ -398,7 +398,7 @@ namespace OpenSim.Framework
|
||||
// Region handles are based on the coordinate of the region corner with lower X and Y
|
||||
// var regions need more work than this to get that right corner from a generic world position
|
||||
// this corner must be on a grid point
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static ulong RegionWorldLocToHandle(uint X, uint Y)
|
||||
{
|
||||
ulong handle = X & 0xffffff00; // make sure it matchs grid coord points.
|
||||
@@ -407,7 +407,7 @@ namespace OpenSim.Framework
|
||||
return handle;
|
||||
}
|
||||
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static ulong RegionGridLocToHandle(uint X, uint Y)
|
||||
{
|
||||
ulong handle = X;
|
||||
@@ -416,14 +416,14 @@ namespace OpenSim.Framework
|
||||
return handle;
|
||||
}
|
||||
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static void RegionHandleToWorldLoc(ulong handle, out uint X, out uint Y)
|
||||
{
|
||||
X = (uint)(handle >> 32);
|
||||
Y = (uint)(handle & 0xfffffffful);
|
||||
}
|
||||
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static void RegionHandleToRegionLoc(ulong handle, out uint X, out uint Y)
|
||||
{
|
||||
X = (uint)(handle >> 40) & 0x00ffffffu; // bring from higher half, divide by 256 and clean
|
||||
@@ -433,14 +433,14 @@ namespace OpenSim.Framework
|
||||
|
||||
// A region location can be 'world coordinates' (meters) or 'region grid coordinates'
|
||||
// grid coordinates have a fixed step of 256m as defined by viewers
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static uint WorldToRegionLoc(uint worldCoord)
|
||||
{
|
||||
return worldCoord >> 8;
|
||||
}
|
||||
|
||||
// Convert a region's 'region grid coordinate' to its 'world coordinate'.
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static uint RegionToWorldLoc(uint regionCoord)
|
||||
{
|
||||
return regionCoord << 8;
|
||||
@@ -592,17 +592,20 @@ namespace OpenSim.Framework
|
||||
return true;
|
||||
}
|
||||
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static T Clamp<T>(T x, T min, T max)
|
||||
where T : IComparable<T>
|
||||
{
|
||||
return x.CompareTo(max) > 0 ? max :
|
||||
x.CompareTo(min) < 0 ? min :
|
||||
x;
|
||||
if(x.CompareTo(max) > 0)
|
||||
return max;
|
||||
|
||||
if(x.CompareTo(min) < 0)
|
||||
return min;
|
||||
return x;
|
||||
}
|
||||
|
||||
// Clamp the maximum magnitude of a vector
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Vector3 ClampV(Vector3 x, float max)
|
||||
{
|
||||
float lenSq = x.LengthSquared();
|
||||
@@ -750,7 +753,7 @@ namespace OpenSim.Framework
|
||||
}
|
||||
}
|
||||
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
static bool IsHexa(char c)
|
||||
{
|
||||
if (c >= '0' && c <= '9')
|
||||
@@ -874,7 +877,7 @@ namespace OpenSim.Framework
|
||||
return ids;
|
||||
}
|
||||
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
static bool IsHexa(byte c)
|
||||
{
|
||||
if (c >= '0' && c <= '9')
|
||||
@@ -2520,7 +2523,7 @@ namespace OpenSim.Framework
|
||||
return found.ToArray();
|
||||
}
|
||||
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static string AppendEndSlash(string path)
|
||||
{
|
||||
int len = path.Length;
|
||||
@@ -2530,7 +2533,7 @@ namespace OpenSim.Framework
|
||||
return path;
|
||||
}
|
||||
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static string TrimEndSlash(string path)
|
||||
{
|
||||
int len = path.Length;
|
||||
@@ -2687,7 +2690,7 @@ namespace OpenSim.Framework
|
||||
return data;
|
||||
}
|
||||
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static int osUTF8Getbytes(string srcstr, byte[] dstarray, int maxdstlen, bool NullTerm = true)
|
||||
{
|
||||
return osUTF8Getbytes(srcstr, dstarray, 0, maxdstlen, NullTerm);
|
||||
@@ -3054,11 +3057,13 @@ namespace OpenSim.Framework
|
||||
|
||||
private static readonly Dictionary<string, int> m_fireAndForgetCallsInProgress = new Dictionary<string, int>();
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static void FireAndForget(System.Threading.WaitCallback callback)
|
||||
{
|
||||
FireAndForget(callback, null, null);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static void FireAndForget(System.Threading.WaitCallback callback, object obj)
|
||||
{
|
||||
FireAndForget(callback, obj, null);
|
||||
@@ -3412,33 +3417,33 @@ namespace OpenSim.Framework
|
||||
|
||||
// returns a timestamp in seconds as double
|
||||
// using the time resolution avaiable to StopWatch
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static double GetTimeStamp()
|
||||
{
|
||||
return Stopwatch.GetTimestamp() * TimeStampClockPeriod;
|
||||
}
|
||||
|
||||
// returns a timestamp in ms as double
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static double GetTimeStampMS()
|
||||
{
|
||||
return Stopwatch.GetTimestamp() * TimeStampClockPeriodMS;
|
||||
}
|
||||
|
||||
// doing math in ticks is usefull to avoid loss of resolution
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static long GetTimeStampTicks()
|
||||
{
|
||||
return Stopwatch.GetTimestamp();
|
||||
}
|
||||
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static double TimeStampTicksToMS(long ticks)
|
||||
{
|
||||
return ticks * TimeStampClockPeriodMS;
|
||||
}
|
||||
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static void AddToGatheredIds(Dictionary<UUID, sbyte> uuids, UUID id, sbyte type)
|
||||
{
|
||||
if (id == UUID.Zero)
|
||||
|
||||
Reference in New Issue
Block a user