dispose method
Releases all resources for this object.
See also:
- isClosed which tracks whether this method has been called.
Implementation
@override
void dispose() {
assert(() {
if (isClosed) {
throw Exception(
'A LlmResponseContext was closed after it had already been closed. '
'LlmResponseContext objects should only be closed when they are at'
'their end of life and will never be used again.',
);
}
return true;
}());
if (_pointer != null) {
// Only call the native finalizer if there actually is native memory,
// because tests may verify that faked results are also closed and calling
// this method in that scenario would cause a segfault.
bindings.LlmInferenceEngine_CloseResponseContext(_pointer!);
}
super.dispose();
}