public interface ReferenceCounted extends ReferenceOwner
INIT, TMP
Modifier and Type | Method and Description |
---|---|
void |
addReferenceChangeListener(ReferenceChangeListener referenceChangeListener)
Add a
ReferenceChangeListener that will be notified whenever the set of references changes |
int |
refCount()
Returns the reference count for this resource.
|
void |
release(ReferenceOwner id)
Releases a resource.
|
default void |
releaseLast() |
void |
releaseLast(ReferenceOwner id)
Releases a resource and checks this is the last usage.
|
void |
removeReferenceChangeListener(ReferenceChangeListener referenceChangeListener)
Remove a
ReferenceChangeListener |
void |
reserve(ReferenceOwner id)
Reserves a resource or throws an Exception.
|
boolean |
reservedBy(ReferenceOwner owner)
Deprecated.
Deprecated with no replacement
|
default void |
reserveTransfer(ReferenceOwner from,
ReferenceOwner to) |
boolean |
tryReserve(ReferenceOwner id)
Tries to reserve a resource and returns if the resource could
be successfully reserved.
|
referenceId, referenceName, temporary
void reserve(ReferenceOwner id) throws IllegalStateException
Each invocation of this method increases the reference count by one.
id
- unique id for this reserveIllegalStateException
- if the resource has already been freed.
I.e. its reference counter has as some point reached zero.default void reserveTransfer(ReferenceOwner from, ReferenceOwner to) throws IllegalStateException
IllegalStateException
boolean tryReserve(ReferenceOwner id) throws IllegalStateException, IllegalArgumentException
Each invocation of this method increases the reference count by one.
id
- unique id for this reserveIllegalStateException
- if the resource has already been freed.
I.e. its reference counter has as some point reached zero.IllegalArgumentException
@Deprecated boolean reservedBy(ReferenceOwner owner) throws IllegalStateException
true
if not sure.owner
- to checkIllegalStateException
void release(ReferenceOwner id) throws IllegalStateException
Each invocation of this method decreases the reference count by one.
id
- unique id for the reserve to be releasedIllegalStateException
- if the resource has already been freed.
I.e. its reference counter has as some point reached zero.void releaseLast(ReferenceOwner id) throws IllegalStateException
Each invocation of this method decreases the reference count by one.
id
- unique id for the reserve to be releasedIllegalStateException
- if the resource has already been freed.
I.e. its reference counter has as some point reached zero.default void releaseLast() throws IllegalStateException
IllegalStateException
int refCount()
void addReferenceChangeListener(ReferenceChangeListener referenceChangeListener)
ReferenceChangeListener
that will be notified whenever the set of references changesreferenceChangeListener
- The listener to addvoid removeReferenceChangeListener(ReferenceChangeListener referenceChangeListener)
ReferenceChangeListener
Uses object equality to determine which to remove so be careful if the listener implements equals
referenceChangeListener
- The listener to removeCopyright © 2023. All rights reserved.