Interface Resource<T extends Resource<T>>
- Type Parameters:
T- The type that is held in this resource.
- All Superinterfaces:
AutoCloseable
- All Known Subinterfaces:
ProtonBuffer,ProtonCompositeBuffer
- All Known Implementing Classes:
Netty4ToProtonBufferAdapter,Netty5ToProtonBufferAdapter,ProtonByteArrayBuffer,ProtonCompositeBufferImpl,SharedResource
Base resource type that provides API for managing ownership and cleaning
up resources that require explicit life-cycle management.
-
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Close the resource and free any managed resources it might own.booleanisClosed()AResourceis closed either following a call to theclose()method or by the resource being transfered by way of thetransfer()method.transfer()Transfers ownership of this resource from one owner to another.
-
Method Details
-
close
void close()Close the resource and free any managed resources it might own. Calling close on a closed resource should not result in any exceptions being thrown.- Specified by:
closein interfaceAutoCloseable
-
transfer
T transfer()Transfers ownership of this resource from one owner to another.Upon transferring a resource the original referenced value is closed and its contents are migrated to a new view that has the same state as the original view but it now the property of the caller and who's life-cycle now must be managed by the caller.
- Returns:
- the a new transfered view of the given resource now owned by the caller.
-
isClosed
boolean isClosed()AResourceis closed either following a call to theclose()method or by the resource being transfered by way of thetransfer()method.- Returns:
- true if this resource is closed, either by being transfered or by direct
close().
-