aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/Util.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Framework/Util.cs')
-rw-r--r--OpenSim/Framework/Util.cs22
1 files changed, 14 insertions, 8 deletions
diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs
index a855767..a42dcc6 100644
--- a/OpenSim/Framework/Util.cs
+++ b/OpenSim/Framework/Util.cs
@@ -156,12 +156,14 @@ namespace OpenSim.Framework
156 public static readonly int MAX_THREADPOOL_LEVEL = 3; 156 public static readonly int MAX_THREADPOOL_LEVEL = 3;
157 157
158 public static double TimeStampClockPeriodMS; 158 public static double TimeStampClockPeriodMS;
159 public static double TimeStampClockPeriod;
159 160
160 static Util() 161 static Util()
161 { 162 {
162 LogThreadPool = 0; 163 LogThreadPool = 0;
163 LogOverloads = true; 164 LogOverloads = true;
164 TimeStampClockPeriodMS = 1000.0D / (double)Stopwatch.Frequency; 165 TimeStampClockPeriod = 1.0D/ (double)Stopwatch.Frequency;
166 TimeStampClockPeriodMS = 1e3 * TimeStampClockPeriod;
165 m_log.InfoFormat("[UTIL] TimeStamp clock with period of {0}ms", Math.Round(TimeStampClockPeriodMS,6,MidpointRounding.AwayFromZero)); 167 m_log.InfoFormat("[UTIL] TimeStamp clock with period of {0}ms", Math.Round(TimeStampClockPeriodMS,6,MidpointRounding.AwayFromZero));
166 } 168 }
167 169
@@ -2221,9 +2223,9 @@ namespace OpenSim.Framework
2221 // might have gotten an oversized array even after the string trim 2223 // might have gotten an oversized array even after the string trim
2222 byte[] data = UTF8.GetBytes(str); 2224 byte[] data = UTF8.GetBytes(str);
2223 2225
2224 if (data.Length > 256) 2226 if (data.Length > 255) //play safe
2225 { 2227 {
2226 int cut = 255; 2228 int cut = 254;
2227 if((data[cut] & 0x80 ) != 0 ) 2229 if((data[cut] & 0x80 ) != 0 )
2228 { 2230 {
2229 while(cut > 0 && (data[cut] & 0xc0) != 0xc0) 2231 while(cut > 0 && (data[cut] & 0xc0) != 0xc0)
@@ -2325,7 +2327,7 @@ namespace OpenSim.Framework
2325 2327
2326 if (data.Length > MaxLength) 2328 if (data.Length > MaxLength)
2327 { 2329 {
2328 int cut = MaxLength -1 ; 2330 int cut = MaxLength - 1 ;
2329 if((data[cut] & 0x80 ) != 0 ) 2331 if((data[cut] & 0x80 ) != 0 )
2330 { 2332 {
2331 while(cut > 0 && (data[cut] & 0xc0) != 0xc0) 2333 while(cut > 0 && (data[cut] & 0xc0) != 0xc0)
@@ -2967,9 +2969,9 @@ namespace OpenSim.Framework
2967 /// <returns></returns> 2969 /// <returns></returns>
2968 public static Int32 EnvironmentTickCount() 2970 public static Int32 EnvironmentTickCount()
2969 { 2971 {
2970 double now = GetTimeStampMS(); 2972 return Environment.TickCount & EnvironmentTickCountMask;
2971 return (int)now;
2972 } 2973 }
2974
2973 const Int32 EnvironmentTickCountMask = 0x3fffffff; 2975 const Int32 EnvironmentTickCountMask = 0x3fffffff;
2974 2976
2975 /// <summary> 2977 /// <summary>
@@ -2994,8 +2996,7 @@ namespace OpenSim.Framework
2994 /// <returns>subtraction of passed prevValue from current Environment.TickCount</returns> 2996 /// <returns>subtraction of passed prevValue from current Environment.TickCount</returns>
2995 public static Int32 EnvironmentTickCountSubtract(Int32 prevValue) 2997 public static Int32 EnvironmentTickCountSubtract(Int32 prevValue)
2996 { 2998 {
2997 double now = GetTimeStampMS(); 2999 return EnvironmentTickCountSubtract(EnvironmentTickCount(), prevValue);
2998 return EnvironmentTickCountSubtract((int)now, prevValue);
2999 } 3000 }
3000 3001
3001 // Returns value of Tick Count A - TickCount B accounting for wrapping of TickCount 3002 // Returns value of Tick Count A - TickCount B accounting for wrapping of TickCount
@@ -3017,6 +3018,11 @@ namespace OpenSim.Framework
3017 3018
3018 // returns a timestamp in ms as double 3019 // returns a timestamp in ms as double
3019 // using the time resolution avaiable to StopWatch 3020 // using the time resolution avaiable to StopWatch
3021 public static double GetTimeStamp()
3022 {
3023 return (double)Stopwatch.GetTimestamp() * TimeStampClockPeriod;
3024 }
3025
3020 public static double GetTimeStampMS() 3026 public static double GetTimeStampMS()
3021 { 3027 {
3022 return (double)Stopwatch.GetTimestamp() * TimeStampClockPeriodMS; 3028 return (double)Stopwatch.GetTimestamp() * TimeStampClockPeriodMS;