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()
Constructs a new AbstractCloseableReferenceCounted instance.
|
Modifier and Type | Method and Description |
---|---|
protected void |
backgroundPerformRelease()
Closes the resource in the background.
|
void |
close()
Closes the resource.
|
boolean |
isClosed()
Checks if this object is closed.
|
void |
release(ReferenceOwner id)
Releases the resource for the given id.
|
void |
releaseLast(ReferenceOwner id)
Releases the resource for the given id and checks the resource is now released.
|
void |
reserve(ReferenceOwner id)
Reserves the resource for the given id.
|
void |
reserveTransfer(ReferenceOwner from,
ReferenceOwner to)
Reserves the resource for the given id.
|
protected void |
setClosed()
Sets the resource as closed.
|
protected void |
setClosing()
Sets the resource as closing in case it is being released in the background.
|
void |
throwExceptionIfClosed()
Throws an exception if the resource is closed.
|
protected void |
throwExceptionIfClosedInSetter()
Throws an exception if the resource is closed while in a setter method.
|
boolean |
tryReserve(ReferenceOwner id)
Tries to reserve the resource for the given id.
|
addReferenceChangeListener, assertReferencesReleased, canReleaseInBackground, clearUsedByThread, createdHere, disableReferenceTracing, enableReferenceTracing, performRelease, refCount, referenceCountedUnmonitored, 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
protected AbstractCloseableReferenceCounted()
public void reserve(ReferenceOwner id) throws IllegalStateException
reserve
in interface ReferenceCounted
reserve
in class AbstractReferenceCounted
id
- unique id for this reserveIllegalStateException
- if already releasedpublic void reserveTransfer(ReferenceOwner from, ReferenceOwner to) throws IllegalStateException
reserveTransfer
in interface ReferenceCounted
reserveTransfer
in class AbstractReferenceCounted
from
- resourceto
- resourceIllegalStateException
- if resource is already releasedpublic void release(ReferenceOwner id) throws IllegalStateException
release
in interface ReferenceCounted
release
in class AbstractReferenceCounted
id
- unique id for this releaseIllegalStateException
- if resource is already releasedpublic void releaseLast(ReferenceOwner id) throws IllegalStateException
releaseLast
in interface ReferenceCounted
releaseLast
in class AbstractReferenceCounted
id
- unique id for this releaseIllegalStateException
- if resource is already releasedpublic boolean tryReserve(ReferenceOwner id) throws IllegalStateException, IllegalArgumentException
tryReserve
in interface ReferenceCounted
tryReserve
in class AbstractReferenceCounted
id
- unique id for this reserveIllegalStateException
- if resource is already releasedIllegalArgumentException
public void close()
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
- if closedprotected void throwExceptionIfClosedInSetter() throws IllegalStateException
IllegalStateException
- if closedpublic boolean isClosed()
QueryCloseable
isClosed
in interface QueryCloseable
Copyright © 2023. All rights reserved.