public class LivenessScope extends ReferenceCounted implements ReleasableLivenessManager
LivenessNode
implementation for providing external scope to one or more LivenessReferent
s.Constructor and Description |
---|
LivenessScope()
Construct a new scope, which must be
LivenessScope.release() d in order to release any subsequently added
LivenessReferent s. |
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, tryIncrementReferenceCount
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
manage, tryManage
getReferentDescription, retainReference
public LivenessScope()
LivenessScope.release()
d in order to release any subsequently added
LivenessReferent
s.public final void transferTo(@NotNull LivenessManager other)
LivenessReferent
s from this LivenessScope
to a compatible
LivenessManager
. Transfer support compatibility is implementation defined.other
- The other LivenessManager
public 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()
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