From d2e48983b914ba8d5d16950c13992cee0a53366c Mon Sep 17 00:00:00 2001 From: 0/0 Date: Mon, 10 Oct 2022 17:37:53 -0600 Subject: [PATCH] add Send and Sync impls --- src/whisper_ctx.rs | 6 ++++++ src/whisper_params.rs | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/src/whisper_ctx.rs b/src/whisper_ctx.rs index f5e9f33..7c3ee96 100644 --- a/src/whisper_ctx.rs +++ b/src/whisper_ctx.rs @@ -453,3 +453,9 @@ impl Drop for WhisperContext { unsafe { whisper_rs_sys::whisper_free(self.ctx) }; } } + +// following implementations are safe +// see https://github.com/ggerganov/whisper.cpp/issues/32#issuecomment-1272790388 +// concurrent usage is prevented by &mut self on methods that modify the struct +unsafe impl Send for WhisperContext {} +unsafe impl Sync for WhisperContext {} diff --git a/src/whisper_params.rs b/src/whisper_params.rs index fb06b4d..7d36c78 100644 --- a/src/whisper_params.rs +++ b/src/whisper_params.rs @@ -112,3 +112,9 @@ impl<'a> FullParams<'a> { self.fp.language = language.as_ptr() as *const _; } } + +// following implementations are safe +// see https://github.com/ggerganov/whisper.cpp/issues/32#issuecomment-1272790388 +// concurrent usage is prevented by &mut self on methods that modify the struct +unsafe impl<'a> Send for FullParams<'a> {} +unsafe impl<'a> Sync for FullParams<'a> {}