saker.util Documentation TaskDoc JavaDoc Packages
public class StrongSoftReference<Textends SoftReference<T>
Reference class that allows the referent to be strongly referenced alongside its soft reference.

This class works the same way as SoftReference, but when constructed, it also holds the referent by a strong reference. This prevents it from being garbage collected until makeSoft() is called.

This class is useful when dynamic caching is implemented. Making a reference soft can allow the referenced object to be garbage collected, but calling makeStrong() again, can allow the client to reuse a not yet garbage collected object instead of creating a new one.

TThe type of the referenced object.
Constructors
public
public
StrongSoftReference(T referent, ReferenceQueue<super T> q)
Methods
public void
Clears this reference object.
public void
Makes this reference soft by clearing its strong reference.
public boolean
Tries to make this reference strong again, by assigning the strong reference to the referent.
public void clear()
Overridden from: Reference
Clears this reference object. Invoking this method will not cause this object to be enqueued.

This method is invoked only by Java code; when the garbage collector clears references it does so directly, without invoking this method.

public void makeSoft()
Makes this reference soft by clearing its strong reference.
public boolean makeStrong()
Tries to make this reference strong again, by assigning the strong reference to the referent.

This method can fail and return false, if the referenced object was already garbage collected. (I.e. SoftReference.get() returns null.)

If this method succeeds, then the following calls to SoftReference.get() will return non-null.

true if the reference was successfully made strong.