Add "close()" method to MP Web Tasks

PiperOrigin-RevId: 527726737
This commit is contained in:
Sebastian Schmidt
2023-04-27 17:16:40 -07:00
committed by Copybara-Service
parent b7e46ec528
commit 5e41d47f3a
3 changed files with 18 additions and 1 deletions
@@ -63,6 +63,7 @@ export declare interface WasmModule {
_bindTextureToCanvas: () => boolean;
_changeBinaryGraph: (size: number, dataPtr: number) => void;
_changeTextGraph: (size: number, dataPtr: number) => void;
_closeGraph: () => void;
_free: (ptr: number) => void;
_malloc: (size: number) => number;
_processFrame: (width: number, height: number, timestamp: number) => void;
@@ -1148,6 +1149,16 @@ export class GraphRunner {
finishProcessing(): void {
this.wasmModule._waitUntilIdle();
}
/**
* Closes the input streams and all calculators for this graph and frees up
* any C++ resources. The graph will not be usable once closed.
*/
closeGraph(): void {
this.wasmModule._closeGraph();
this.wasmModule.simpleListeners = undefined;
this.wasmModule.emptyPacketListeners = undefined;
}
}
// Quick private helper to run the given script safely