separate updateSize in JObjectLRU

This commit is contained in:
2024-07-28 19:42:22 +02:00
parent 20904ed3ad
commit be4a1ba165
2 changed files with 9 additions and 4 deletions

View File

@@ -62,8 +62,6 @@ public class JObjectLRU {
_statusExecutor.shutdownNow();
}
// Called in JObjectManager getters to add into cache,
// and when resolving/modifying to update size
public void notifyAccess(JObject<?> obj) {
if (obj.getData() == null) return;
long size = jObjectSizeEstimator.estimateObjectSize(obj.getData());
@@ -80,4 +78,11 @@ public class JObjectLRU {
}
}
}
public void updateSize(JObject<?> obj) {
long size = jObjectSizeEstimator.estimateObjectSize(obj.getData());
synchronized (_cache) {
_cache.put(obj, size);
}
}
}

View File

@@ -179,7 +179,7 @@ public class JObjectResolver {
}
public void onResolution(JObject<?> self) {
jObjectLRU.notifyAccess(self);
jObjectLRU.updateSize(self);
}
public void removeLocal(JObject<?> jObject, String name) {
@@ -200,7 +200,7 @@ public class JObjectResolver {
public <T extends JObjectData> void notifyWrite(JObject<T> self, boolean metaChanged,
boolean externalChanged, boolean hasDataChanged) {
self.assertRWLock();
jObjectLRU.notifyAccess(self);
jObjectLRU.updateSize(self);
if (metaChanged || hasDataChanged)
jObjectWriteback.markDirty(self);
if (metaChanged)