public interface ReferenceChangeListener
ReferenceCounted
changes. Typical uses include tracking resource ownership and diagnosing
reference leaks during development.
Callbacks are invoked by ReferenceCounted implementations via
ReferenceChangeListenerManager in the order that listeners were
registered. Implementations must avoid long or blocking work as callbacks can
be triggered while the owning object is holding internal locks, risking
deadlock.
| Modifier and Type | Method and Description |
|---|---|
default void |
onReferenceAdded(ReferenceCounted referenceCounted,
ReferenceOwner referenceOwner)
Invoked immediately after a reservation is made on the supplied
ReferenceCounted instance. |
default void |
onReferenceRemoved(@Nullable ReferenceCounted referenceCounted,
ReferenceOwner referenceOwner)
Invoked after a reservation is released from the supplied
ReferenceCounted instance. |
default void |
onReferenceTransferred(ReferenceCounted referenceCounted,
ReferenceOwner fromOwner,
ReferenceOwner toOwner)
Invoked after a reservation is moved from one owner to another on the
supplied
ReferenceCounted instance. |
default void onReferenceAdded(ReferenceCounted referenceCounted, ReferenceOwner referenceOwner)
ReferenceCounted instance.
The call may occur while the owner object is synchronized. Keep the implementation short and non-blocking to avoid deadlock.
referenceCounted - the resource whose reference count increasedreferenceOwner - the owner of the new referencedefault void onReferenceRemoved(@Nullable
@Nullable ReferenceCounted referenceCounted,
ReferenceOwner referenceOwner)
ReferenceCounted instance.
As above, the call can happen whilst the owner is holding locks, so avoid blocking operations.
referenceCounted - the resource whose reference count decreasedreferenceOwner - the owner whose reference was removed or null
if unknowndefault void onReferenceTransferred(ReferenceCounted referenceCounted, ReferenceOwner fromOwner, ReferenceOwner toOwner)
ReferenceCounted instance.
Implementations should again avoid lengthy work as the call may be made
within the ReferenceCounted's critical section.
referenceCounted - the resource whose reference was transferredfromOwner - the previous owner of the referencetoOwner - the new owner of the referenceCopyright © 2026 Chronicle Software Ltd. All rights reserved.