public class LivenessArtifact extends ReferenceCounted implements Serializable
LivenessNode
. These referents are added to the current top of the
LivenessScopeStack
on construction or deserialization.Modifier | Constructor and Description |
---|---|
protected |
LivenessArtifact() |
Modifier and Type | Method and Description |
---|---|
protected void |
destroy()
Attempt to release (destructively when necessary) resources held by this object.
|
void |
dropReference()
Drop a previously-retained reference to this referent.
|
WeakReference<? extends LivenessReferent> |
getWeakReference()
Get a
WeakReference to this referent. |
void |
initializeTransientFieldsForLiveness()
Package-private for
Serializable sub-classes to use in readObject only. |
void |
manageWithCurrentScope()
Add this artifact to the current manager provided by the
LivenessScopeStack . |
protected void |
onReferenceCountAtZero()
Callback method that will be invoked when the reference count returns to zero.
|
boolean |
tryManage(LivenessReferent referent)
Attempt to add the specified referent to this manager.
|
boolean |
tryRetainReference()
If this referent is "live", behave as
LivenessReferent.retainReference() and return true. |
protected void |
unmanage(Collection<? extends LivenessReferent> referents)
For each referent in referents, if this manages referent one or more times, drop one such reference.
|
protected void |
unmanage(LivenessReferent referent)
If this manages referent one or more times, drop one such reference.
|
append, decrementReferenceCount, incrementReferenceCount, resetReferenceCount, toString, tryDecrementReferenceCount, tryIncrementReferenceCount
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getReferentDescription, retainReference
manage
public final void manageWithCurrentScope()
LivenessScopeStack
.protected final void unmanage(@NotNull LivenessReferent referent)
If this manages referent one or more times, drop one such reference.
referent
- The referent to dropprotected final void unmanage(@NotNull Collection<? extends LivenessReferent> referents)
For each referent in referents, if this manages referent one or more times, drop one such reference.
referents
- The referents to drop@VisibleForTesting public final void initializeTransientFieldsForLiveness()
Serializable
sub-classes to use in readObject
only.
Public to allow unit tests in another package to work around mock issues where the constructor is never invoked.public final boolean tryRetainReference()
LivenessReferent
LivenessReferent.retainReference()
and return true.
Otherwise, returns false rather than throwing an exception.tryRetainReference
in interface LivenessReferent
public final void dropReference()
LivenessReferent
dropReference
in interface LivenessReferent
public WeakReference<? extends LivenessReferent> getWeakReference()
LivenessReferent
WeakReference
to this referent. This may be cached, or newly created.getWeakReference
in interface LivenessReferent
public final boolean tryManage(@NotNull LivenessReferent referent)
LivenessManager
tryManage
in interface LivenessManager
referent
- The referent to addprotected void destroy()
Attempt to release (destructively when necessary) resources held by this object. This may render the object unusable for subsequent operations. Implementations should be sure to call super.destroy().
This is intended to only ever be used as a side effect of decreasing the reference count to 0.
protected final void onReferenceCountAtZero()
ReferenceCounted
onReferenceCountAtZero
in class ReferenceCounted