public abstract class AbstractCloseableReferenceCounted extends AbstractReferenceCounted implements ManagedCloseable
referenceCounted, WARN_COUNT, WARN_NS
INIT, TMP
DISABLE_SINGLE_THREADED_CHECK
Modifier | Constructor and Description |
---|---|
protected |
AbstractCloseableReferenceCounted() |
Modifier and Type | Method and Description |
---|---|
protected void |
backgroundPerformRelease() |
void |
close()
Closes this resource, potentially preventing parts of it from being used again
and potentially relinquishing resources held.
|
boolean |
isClosed()
Is this object closed
|
void |
release(ReferenceOwner id)
Releases a resource.
|
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.
|
void |
reserveTransfer(ReferenceOwner from,
ReferenceOwner to) |
protected void |
setClosed()
When actually closed.
|
protected void |
setClosing()
Set closing in case it is being released in the background.
|
void |
throwExceptionIfClosed() |
protected void |
throwExceptionIfClosedInSetter() |
boolean |
tryReserve(ReferenceOwner id)
Tries to reserve a resource and returns if the resource could
be successfully reserved.
|
addReferenceChangeListener, assertReferencesReleased, canReleaseInBackground, clearUsedByThread, createdHere, disableReferenceTracing, enableReferenceTracing, performRelease, refCount, referenceId, removeReferenceChangeListener, reservedBy, singleThreadedCheckDisabled, singleThreadedCheckReset, threadSafetyCheck, throwExceptionIfNotReleased, throwExceptionIfReleased, toString, unmonitor, warnAndReleaseIfNotReleased
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
createdHere, warnAndCloseIfNotClosed
closeQuietly, closeQuietly
isClosing
onReleased
releaseLast
referenceName, temporary
public void reserve(ReferenceOwner id) throws IllegalStateException
ReferenceCounted
Each invocation of this method increases the reference count by one.
reserve
in interface ReferenceCounted
reserve
in class AbstractReferenceCounted
id
- unique id for this reserveIllegalStateException
- if the resource has already been freed.
I.e. its reference counter has as some point reached zero.public void reserveTransfer(ReferenceOwner from, ReferenceOwner to) throws IllegalStateException
reserveTransfer
in interface ReferenceCounted
reserveTransfer
in class AbstractReferenceCounted
IllegalStateException
public void release(ReferenceOwner id) throws IllegalStateException
ReferenceCounted
Each invocation of this method decreases the reference count by one.
release
in interface ReferenceCounted
release
in class AbstractReferenceCounted
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.public void releaseLast(ReferenceOwner id) throws IllegalStateException
ReferenceCounted
Each invocation of this method decreases the reference count by one.
releaseLast
in interface ReferenceCounted
releaseLast
in class AbstractReferenceCounted
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.public boolean tryReserve(ReferenceOwner id) throws IllegalStateException, IllegalArgumentException
ReferenceCounted
Each invocation of this method increases the reference count by one.
tryReserve
in interface ReferenceCounted
tryReserve
in class AbstractReferenceCounted
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
public void close()
Closeable
This method is idem-potent.
close
in interface Closeable
close
in interface AutoCloseable
protected void backgroundPerformRelease()
backgroundPerformRelease
in class AbstractReferenceCounted
protected void setClosing()
protected void setClosed()
public void throwExceptionIfClosed() throws IllegalStateException
throwExceptionIfClosed
in interface ManagedCloseable
IllegalStateException
protected void throwExceptionIfClosedInSetter() throws IllegalStateException
IllegalStateException
public boolean isClosed()
QueryCloseable
isClosed
in interface QueryCloseable
Copyright © 2023. All rights reserved.