public class LivenessScope extends ReferenceCounted implements ReleasableLivenessManager
LivenessNode implementation for providing external scope to one or more LivenessReferents.| Constructor and Description |
|---|
LivenessScope()
Construct a new scope, which must be
LivenessScope.release()d in order to release any subsequently added
LivenessReferents. |
| 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. |
protected void |
onReferenceCountAtZero()
Callback method that will be invoked when the reference count returns to zero.
|
void |
release()
Release all referents previously added to this scope in its capacity as a
LivenessManager, unless other
references to this scope are retained in its capacity as a LivenessReferent. |
void |
transferTo(LivenessManager other)
|
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. |
append, decrementReferenceCount, incrementReferenceCount, resetReferenceCount, toString, tryDecrementReferenceCount, tryIncrementReferenceCountclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitmanage, tryManagegetReferentDescription, retainReferencepublic LivenessScope()
LivenessScope.release()d in order to release any subsequently added
LivenessReferents.public final void transferTo(@NotNull
LivenessManager other)
LivenessReferents from this LivenessScope to a compatible
LivenessManager. Transfer support compatibility is implementation defined.other - The other LivenessManagerpublic final void release()
LivenessManager, unless other
references to this scope are retained in its capacity as a LivenessReferent.release in interface ReleasableLivenessManager@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()
LivenessReferentLivenessReferent.retainReference() and return true.
Otherwise, returns false rather than throwing an exception.tryRetainReference in interface LivenessReferentpublic final void dropReference()
LivenessReferentdropReference in interface LivenessReferentpublic WeakReference<? extends LivenessReferent> getWeakReference()
LivenessReferentWeakReference to this referent. This may be cached, or newly created.getWeakReference in interface LivenessReferentpublic final boolean tryManage(@NotNull
LivenessReferent referent)
LivenessManagertryManage in interface LivenessManagerreferent - 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()
ReferenceCountedonReferenceCountAtZero in class ReferenceCounted