public interface ReferenceCounted extends ReferenceOwner
INIT
Modifier and Type | Method and Description |
---|---|
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 |
reserve(ReferenceOwner id)
Reserves a resource or throws an Exception.
|
boolean |
reservedBy(ReferenceOwner owner)
Best effort check the owner has reserved it.
|
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
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.boolean reservedBy(ReferenceOwner owner)
owner
- to checkvoid 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()
Copyright © 2020. All rights reserved.