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

Avoid polymorphic Entry.ref

Always use CacheSoftReference, even for initial null referent. Simply do
not enqueue the CacheSoftReference in this case.
parent 15d762e6
No related branches found
No related tags found
No related merge requests found
...@@ -21,6 +21,12 @@ public class SoftRefCache< K, V > implements Cache< K, V > ...@@ -21,6 +21,12 @@ public class SoftRefCache< K, V > implements Cache< K, V >
{ {
private final Entry entry; private final Entry entry;
public CacheSoftReference( final V referent )
{
super( referent );
this.entry = null;
}
public CacheSoftReference( final V referent, final Entry entry ) public CacheSoftReference( final V referent, final Entry entry )
{ {
super( referent, queue ); super( referent, queue );
...@@ -75,7 +81,7 @@ public class SoftRefCache< K, V > implements Cache< K, V > ...@@ -75,7 +81,7 @@ public class SoftRefCache< K, V > implements Cache< K, V >
{ {
final K key; final K key;
private SoftReference< V > ref; private CacheSoftReference ref;
private CachePhantomReference< V > phantomRef; private CachePhantomReference< V > phantomRef;
...@@ -86,7 +92,7 @@ public class SoftRefCache< K, V > implements Cache< K, V > ...@@ -86,7 +92,7 @@ public class SoftRefCache< K, V > implements Cache< K, V >
public Entry( final K key ) public Entry( final K key )
{ {
this.key = key; this.key = key;
this.ref = new SoftReference<>( null ); this.ref = new CacheSoftReference( null );
this.phantomRef = null; this.phantomRef = null;
this.remover = null; this.remover = null;
this.loaded = false; this.loaded = false;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment