Skip to content
Snippets Groups Projects
Commit b5e380f3 authored by Tobias Pietzsch's avatar Tobias Pietzsch
Browse files

javadoc

parent 54d5b8b6
No related branches found
No related tags found
No related merge requests found
package bdv.cache;
// TODO: rename, refactor, document
import java.lang.ref.SoftReference;
import java.lang.ref.WeakReference;
/**
* A cache associating keys {@code K} to values {@code V}. Key-value pairs are
* added manually to the cache. When and which entries are evicted is
* implementation-specific.
* <p>
* Values can be added to the cache with two different "priorities".
* <ul>
* <li>Values added with {@link #putWeak(Object, Object)} can be discarded
* freely (roughly equivalent to maintaining a {@link WeakReference} to the
* value). Use for values that are cheap to (re-)create.</li>
* <li>Values added with {@link #putSoft(Object, Object)} are discarded only if
* the need arises (roughly equivalent to maintaining a {@link SoftReference} to
* the value). Use for values that are expensive to (re-)create.</li>
* </ul>
*
* @param <K>
* key type.
* @param <V>
* value type.
*
* @author Tobias Pietzsch &lt;tobias.pietzsch@gmail.com&gt;
*/
public interface WeakSoftCache< K, V >
{
public void putWeak( final K key, final V value );
......
......@@ -6,7 +6,17 @@ import java.lang.ref.SoftReference;
import java.lang.ref.WeakReference;
import java.util.concurrent.ConcurrentHashMap;
//TODO: rename, refactor, document
/**
* Implementation of {@link WeakSoftCache} using {@link WeakReference}s and
* {@link SoftReference}s in a {@link ConcurrentHashMap}.
*
* @param <K>
* key type
* @param <V>
* value type
*
* @author Tobias Pietzsch &lt;tobias.pietzsch@gmail.com&gt;
*/
public class WeakSoftCacheImp< K, V > implements WeakSoftCache< K, V >
{
public static final int MAX_PER_FRAME_FINALIZE_ENTRIES = 500;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment