Update svn properties, minor formatting cleanup.

0.6.0-stable
Jeff Ames 2008-08-08 06:39:35 +00:00
parent 1040f3f454
commit 657af5e611
2 changed files with 463 additions and 463 deletions

View File

@ -187,11 +187,11 @@ namespace Opensim.Framework
{ {
public int Compare(CacheItemBase a, CacheItemBase b) public int Compare(CacheItemBase a, CacheItemBase b)
{ {
if(a == null && b == null) if (a == null && b == null)
return 0; return 0;
if(a == null) if (a == null)
return -1; return -1;
if(b == null) if (b == null)
return 1; return 1;
return(a.lastUsed.CompareTo(b.lastUsed)); return(a.lastUsed.CompareTo(b.lastUsed));
@ -244,7 +244,7 @@ namespace Opensim.Framework
// //
public int Count public int Count
{ {
get { lock(m_Index) { return m_Index.Count; } } get { lock (m_Index) { return m_Index.Count; } }
} }
// Maximum number of items this cache will hold // Maximum number of items this cache will hold
@ -257,9 +257,9 @@ namespace Opensim.Framework
private void SetSize(int newSize) private void SetSize(int newSize)
{ {
lock(m_Index) lock (m_Index)
{ {
if(Count <= Size) if (Count <= Size)
return; return;
m_Index.Sort(new SortLRU()); m_Index.Sort(new SortLRU());
@ -282,17 +282,17 @@ namespace Opensim.Framework
{ {
CacheItemBase item = null; CacheItemBase item = null;
lock(m_Index) lock (m_Index)
{ {
item = m_Index.Find(delegate(CacheItemBase i) item = m_Index.Find(delegate(CacheItemBase i)
{ {
if(i.uuid == index) if (i.uuid == index)
return true; return true;
return false; return false;
}); });
} }
if(item == null) if (item == null)
{ {
Expire(true); Expire(true);
return null; return null;
@ -313,7 +313,7 @@ namespace Opensim.Framework
{ {
CacheItemBase item = GetItem(index); CacheItemBase item = GetItem(index);
if(item == null) if (item == null)
return null; return null;
return item.Retrieve(); return item.Retrieve();
@ -325,18 +325,18 @@ namespace Opensim.Framework
public virtual Object Get(LLUUID index, FetchDelegate fetch) public virtual Object Get(LLUUID index, FetchDelegate fetch)
{ {
Object item = Get(index); Object item = Get(index);
if(item != null) if (item != null)
return item; return item;
Object data = fetch(index); Object data = fetch(index);
if(data == null) if (data == null)
{ {
if((m_Flags & CacheFlags.CacheMissing) != 0) if ((m_Flags & CacheFlags.CacheMissing) != 0)
{ {
lock(m_Index) lock (m_Index)
{ {
CacheItemBase missing = new CacheItemBase(index); CacheItemBase missing = new CacheItemBase(index);
if(!m_Index.Contains(missing)) if (!m_Index.Contains(missing))
m_Index.Add(missing); m_Index.Add(missing);
} }
} }
@ -353,7 +353,7 @@ namespace Opensim.Framework
{ {
Type container; Type container;
switch(m_Medium) switch (m_Medium)
{ {
case CacheMedium.Memory: case CacheMedium.Memory:
container = typeof(MemoryCacheItem); container = typeof(MemoryCacheItem);
@ -379,17 +379,17 @@ namespace Opensim.Framework
CacheItemBase item; CacheItemBase item;
lock(m_Index) lock (m_Index)
{ {
if(m_Index.Contains(new CacheItemBase(index))) if (m_Index.Contains(new CacheItemBase(index)))
{ {
if((m_Flags & CacheFlags.AllowUpdate) != 0) if ((m_Flags & CacheFlags.AllowUpdate) != 0)
{ {
item = GetItem(index); item = GetItem(index);
item.hits++; item.hits++;
item.lastUsed = DateTime.Now; item.lastUsed = DateTime.Now;
if(m_DefaultTTL.Ticks != 0) if (m_DefaultTTL.Ticks != 0)
item.expires = DateTime.Now + m_DefaultTTL; item.expires = DateTime.Now + m_DefaultTTL;
item.Store(data); item.Store(data);
@ -400,7 +400,7 @@ namespace Opensim.Framework
item = (CacheItemBase)Activator.CreateInstance(container, item = (CacheItemBase)Activator.CreateInstance(container,
parameters); parameters);
if(m_DefaultTTL.Ticks != 0) if (m_DefaultTTL.Ticks != 0)
item.expires = DateTime.Now + m_DefaultTTL; item.expires = DateTime.Now + m_DefaultTTL;
m_Index.Add(item); m_Index.Add(item);
@ -410,16 +410,16 @@ namespace Opensim.Framework
protected virtual void Expire(bool getting) protected virtual void Expire(bool getting)
{ {
if(getting && (m_Strategy == CacheStrategy.Aggressive)) if (getting && (m_Strategy == CacheStrategy.Aggressive))
return; return;
if(m_DefaultTTL.Ticks != 0) if (m_DefaultTTL.Ticks != 0)
{ {
DateTime now= System.DateTime.Now; DateTime now= System.DateTime.Now;
foreach (CacheItemBase item in new List<CacheItemBase>(m_Index)) foreach (CacheItemBase item in new List<CacheItemBase>(m_Index))
{ {
if(item.expires.Ticks == 0 || if (item.expires.Ticks == 0 ||
item.expires <= now) item.expires <= now)
m_Index.Remove(item); m_Index.Remove(item);
} }
@ -428,28 +428,28 @@ namespace Opensim.Framework
switch (m_Strategy) switch (m_Strategy)
{ {
case CacheStrategy.Aggressive: case CacheStrategy.Aggressive:
if(Count < Size) if (Count < Size)
return; return;
lock(m_Index) lock (m_Index)
{ {
m_Index.Sort(new SortLRU()); m_Index.Sort(new SortLRU());
m_Index.Reverse(); m_Index.Reverse();
int target = (int)((float)Size * 0.9); int target = (int)((float)Size * 0.9);
if(target == Count) // Cover ridiculous cache sizes if (target == Count) // Cover ridiculous cache sizes
return; return;
ExpireDelegate doExpire = OnExpire; ExpireDelegate doExpire = OnExpire;
if(doExpire != null) if (doExpire != null)
{ {
List<CacheItemBase> candidates = List<CacheItemBase> candidates =
m_Index.GetRange(target, Count - target); m_Index.GetRange(target, Count - target);
foreach (CacheItemBase i in candidates) foreach (CacheItemBase i in candidates)
{ {
if(doExpire(i.uuid)) if (doExpire(i.uuid))
m_Index.Remove(i); m_Index.Remove(i);
} }
} }

View File

@ -464,10 +464,10 @@ namespace OpenSim.Region.ClientStack.LindenUDP
{ {
lock (m_DupeTracker) lock (m_DupeTracker)
{ {
if(m_DupeTracker.Count < 1024) if (m_DupeTracker.Count < 1024)
return; return;
if(System.Environment.TickCount - m_DupeTrackerLastCheck < 2000) if (System.Environment.TickCount - m_DupeTrackerLastCheck < 2000)
return; return;
m_DupeTrackerLastCheck = System.Environment.TickCount; m_DupeTrackerLastCheck = System.Environment.TickCount;
@ -726,7 +726,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
// Assign sequence number here to prevent out of order packets // Assign sequence number here to prevent out of order packets
packet.Header.Sequence = NextPacketSequenceNumber(); packet.Header.Sequence = NextPacketSequenceNumber();
lock(m_NeedAck) lock (m_NeedAck)
{ {
// We want to see that packet arrive if it's reliable // We want to see that packet arrive if it's reliable
if (packet.Header.Reliable) if (packet.Header.Reliable)