Skip to content

Commit

Permalink
feat: impl drop for interpreter
Browse files Browse the repository at this point in the history
  • Loading branch information
uttarayan21 committed Sep 21, 2024
1 parent ceb83d3 commit ed12f3d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,8 @@
cargo-nextest
cargo-hakari
cargo-deny
rust-cbindgen
cargo-semver-checks
rust-bindgen
]
++ (lib.optionals pkgs.stdenv.isDarwin [
darwin.apple_sdk.frameworks.OpenCL
Expand Down
7 changes: 7 additions & 0 deletions src/interpreter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,12 @@ pub struct Interpreter {

unsafe impl Send for Interpreter {}

impl Drop for Interpreter {
fn drop(&mut self) {
unsafe { mnn_sys::Interpreter_destroy(self.inner) }
}
}

impl Interpreter {
pub fn from_file(path: impl AsRef<Path>) -> Result<Self> {
let path = path.as_ref();
Expand Down Expand Up @@ -636,3 +642,4 @@ fn try_to_drop_interpreter_before_session() {
drop(interpreter);
drop(session);
}

0 comments on commit ed12f3d

Please sign in to comment.