mirror of
https://github.com/opensim/opensim.git
synced 2026-08-06 17:32:42 +08:00
waste some memory on serialized environment caching. we could live without all that locking
This commit is contained in:
@@ -98,6 +98,8 @@ namespace OpenSim.Framework
|
||||
Cycle = new DayCycle();
|
||||
Cycle.FromWLOSD(array);
|
||||
}
|
||||
|
||||
InvalidateCaches();
|
||||
}
|
||||
|
||||
public OSD ToWLOSD(UUID message, UUID region)
|
||||
@@ -244,6 +246,8 @@ namespace OpenSim.Framework
|
||||
Cycle.skyframes.Add(sky.Name, sky);
|
||||
track = new DayCycle.TrackEntry(-1, sky.Name);
|
||||
Cycle.skyTrack0.Add(track);
|
||||
|
||||
InvalidateCaches();
|
||||
}
|
||||
|
||||
public RegionLightShareData ToLightShare()
|
||||
@@ -346,6 +350,7 @@ namespace OpenSim.Framework
|
||||
}
|
||||
|
||||
IsLegacy = false;
|
||||
InvalidateCaches();
|
||||
}
|
||||
|
||||
public void SortAltitudes()
|
||||
@@ -380,6 +385,9 @@ namespace OpenSim.Framework
|
||||
return false;
|
||||
Cycle = new DayCycle();
|
||||
Cycle.FromOSD(map);
|
||||
|
||||
InvalidateCaches();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -416,6 +424,8 @@ namespace OpenSim.Framework
|
||||
}
|
||||
if(ok && !string.IsNullOrWhiteSpace(name))
|
||||
Cycle.Name = name;
|
||||
|
||||
InvalidateCaches();
|
||||
return ok;
|
||||
}
|
||||
|
||||
@@ -436,6 +446,63 @@ namespace OpenSim.Framework
|
||||
return env;
|
||||
}
|
||||
|
||||
public readonly object m_cachedbytesLock = new object();
|
||||
public byte[] m_cachedbytes = null;
|
||||
public byte[] m_cachedWLbytes = null;
|
||||
|
||||
public void InvalidateCaches()
|
||||
{
|
||||
lock (m_cachedbytesLock)
|
||||
{
|
||||
m_cachedbytes = null;
|
||||
m_cachedWLbytes = null;
|
||||
}
|
||||
}
|
||||
|
||||
public byte[] ToCapBytes(UUID regionID, int parcelID)
|
||||
{
|
||||
//byte[] ret = m_cachedbytes;
|
||||
//if(ret != null)
|
||||
// return ret;
|
||||
|
||||
lock (m_cachedbytesLock)
|
||||
{
|
||||
byte[] ret = m_cachedbytes;
|
||||
if (ret == null)
|
||||
{
|
||||
OSDMap map = new OSDMap();
|
||||
OSDMap cenv = (OSDMap)ToOSD();
|
||||
cenv["parcel_id"] = parcelID;
|
||||
cenv["region_id"] = regionID;
|
||||
map["environment"] = cenv;
|
||||
map["parcel_id"] = parcelID;
|
||||
map["success"] = true;
|
||||
ret = OSDParser.SerializeLLSDXmlToBytes(map);
|
||||
m_cachedbytes = ret;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
public byte[] ToCapWLBytes(UUID messageID, UUID regionID)
|
||||
{
|
||||
//byte[] ret = m_cachedWLbytes;
|
||||
//if (ret != null)
|
||||
// return ret;
|
||||
|
||||
lock (m_cachedbytesLock)
|
||||
{
|
||||
byte[] ret = m_cachedWLbytes;
|
||||
if (ret == null)
|
||||
{
|
||||
OSD d = ToWLOSD(messageID, regionID);
|
||||
ret = OSDParser.SerializeLLSDXmlToBytes(d);
|
||||
m_cachedWLbytes = ret;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
public static ViewerEnvironment FromOSDString(string s)
|
||||
{
|
||||
try
|
||||
|
||||
Reference in New Issue
Block a user