public abstract class CrtResource extends Object implements AutoCloseable
Constructor and Description |
---|
CrtResource() |
Modifier and Type | Method and Description |
---|---|
protected void |
acquireNativeHandle(long handle)
Takes ownership of a native object where the native pointer is tracked as a long.
|
<T extends CrtResource> |
addReferenceTo(T resource)
Marks a resource as referenced by this resource.
|
protected abstract boolean |
canReleaseReferencesImmediately()
Override that determines whether a resource releases its dependencies at the same time the native handle is released or if it waits.
|
void |
close()
Decrements the reference count to this resource.
|
static void |
collectNativeResources(java.util.function.Consumer<String> fn) |
long |
getNativeHandle()
returns the native handle associated with this CRTResource.
|
protected boolean |
isNativeResource()
Is this an actual native resource (true) or does it just track native resources and use the close/shutdown/referencing
aspects (false)?
|
boolean |
isNull()
Checks if this resource's native handle is NULL.
|
static void |
logNativeResources()
Debug method to log all of the currently un-closed CRTResource objects.
|
protected abstract void |
releaseNativeHandle()
Required override method that must begin the release process of the acquired native handle
|
protected void |
releaseReferences()
Decrements the ref counts for all resources referenced by this resource.
|
static void |
waitForNoResources()
Debug/test method to wait for the CRTResource count to drop to zero.
|
public <T extends CrtResource> T addReferenceTo(T resource)
resource
- The referenced subresourceprotected void acquireNativeHandle(long handle)
handle
- pointer to the native object being acquiredpublic long getNativeHandle()
protected abstract void releaseNativeHandle()
protected abstract boolean canReleaseReferencesImmediately()
public boolean isNull()
protected boolean isNativeResource()
public void close()
close
in interface AutoCloseable
protected void releaseReferences()
public static void collectNativeResources(java.util.function.Consumer<String> fn)
public static void logNativeResources()
public static void waitForNoResources()
Copyright © 2019. All rights reserved.