Package io.github.givimad.whisperjni
Class WhisperJNI.WhisperJNIPointer
java.lang.Object
io.github.givimad.whisperjni.WhisperJNI.WhisperJNIPointer
- All Implemented Interfaces:
AutoCloseable
- Direct Known Subclasses:
WhisperContext,WhisperGrammar,WhisperState
- Enclosing class:
- WhisperJNI
protected abstract static class WhisperJNI.WhisperJNIPointer
extends Object
implements AutoCloseable
In order to avoid sharing pointers between the c++ and java, we use this
util base class which holds a random integer id generated in the whisper.cpp wrapper.
- Author:
- Miguel Álvarez Díez - Initial contribution
-
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedWhisperJNIPointer(int ref) Creates a new object used to represent a struct pointer on the native library. -
Method Summary
Modifier and TypeMethodDescriptionprotected static voidAsserts the provided pointer is still available.protected booleanReturn true if native memory is freeprotected voidrelease()Mark the point as releasedMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.lang.AutoCloseable
close
-
Field Details
-
ref
protected final int refNative pointer reference identifier.
-
-
Constructor Details
-
WhisperJNIPointer
protected WhisperJNIPointer(int ref) Creates a new object used to represent a struct pointer on the native library.- Parameters:
ref- a random integer id generated by the native wrapper
-
-
Method Details
-
assertAvailable
Asserts the provided pointer is still available.- Parameters:
pointer- aWhisperJNI.WhisperJNIPointerinstance representing a pointer.
-
isReleased
protected boolean isReleased()Return true if native memory is free- Returns:
- a boolean indicating if the native data was already released
-
release
protected void release()Mark the point as released
-