com.maxifier.mxcache.impl.caches.def.ObjectShortWeakTroveStorage Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of mxcache-runtime Show documentation
Show all versions of mxcache-runtime Show documentation
Constains all classes necessary for launching a MxCache-instrumentated application
/*
* Copyright (c) 2008-2014 Maxifier Ltd. All Rights Reserved.
*/
package com.maxifier.mxcache.impl.caches.def;
import com.maxifier.mxcache.transform.SmartReference;
import java.util.*;
/**
* THIS IS GENERATED CLASS! DON'T EDIT IT MANUALLY!
*
* GENERATED FROM O2PWeakTroveStorage.template
*
* @author Andrey Yakoushin ([email protected])
* @author Alexander Kochurov ([email protected])
*/
public class ObjectShortWeakTroveStorage extends ObjectShortTroveStorage {
private final List removed = Collections.synchronizedList(new ArrayList());
public ObjectShortWeakTroveStorage() {
}
public ObjectShortWeakTroveStorage(gnu.trove.strategy.HashingStrategy strategy) {
super(strategy);
}
private void cleanup() {
for(T t: removed) {
remove(t);
}
removed.clear();
}
@Override
public short load(T o) {
cleanup();
return super.load(o);
}
@Override
public void save(final T o, short t) {
cleanup();
o.setCallback(new Callback(o));
super.save(o, t);
}
private class Callback implements Runnable {
private final T o;
public Callback(T o) {
this.o = o;
}
@Override
public void run() {
removed.add(o);
}
}
}