Asylo
Public Member Functions | Protected Member Functions | List of all members
com.asylo.client.AutoCloseablePointer Class Referenceabstract

A closeable Java wrapper to hold a native object pointer. More...

Inheritance diagram for com.asylo.client.AutoCloseablePointer:
Inheritance graph
[legend]
Collaboration diagram for com.asylo.client.AutoCloseablePointer:
Collaboration graph
[legend]

Public Member Functions

void close ()
 This function hands over control to the child class by calling closeNative(long) for cleaning up the native resources and memory. More...
 

Protected Member Functions

 AutoCloseablePointer (final long pointer)
 
final long getPointer ()
 
abstract void closeNative (final long pointer)
 Child classes should free up native resources and memory when this function is invoked. More...
 

Detailed Description

A closeable Java wrapper to hold a native object pointer.

Child classes will map to the corresponding Asylo C++ classes. Objects of the child classes will also have memory allocated in the native heap. Java's garbage collector does not manage native memory, therefore, these objects must be explicitly closed.

Closing the objects of the inherited classes will denote that they are no longer needed and its native memory can be released. Inherited classes need to deallocate any resources, or memory allocated for the native objects when closeNative(long) is invoked. After closing an object, it is unsafe to use that object or call its APIs and it can lead to undefined behavior.

Constructor & Destructor Documentation

◆ AutoCloseablePointer()

com.asylo.client.AutoCloseablePointer.AutoCloseablePointer ( final long  pointer)
inlineprotected

Member Function Documentation

◆ close()

void com.asylo.client.AutoCloseablePointer.close ( )
inline

This function hands over control to the child class by calling closeNative(long) for cleaning up the native resources and memory.

After a successful call it resets the pointer to 0 and all future invocations of this function will be ignored.

◆ closeNative()

abstract void com.asylo.client.AutoCloseablePointer.closeNative ( final long  pointer)
abstractprotected

Child classes should free up native resources and memory when this function is invoked.

Parameters
pointerPointer value of the corresponding native object.

◆ getPointer()

final long com.asylo.client.AutoCloseablePointer.getPointer ( )
inlineprotected

The documentation for this class was generated from the following file: