add Send and Sync impls

This commit is contained in:
0/0 2022-10-10 17:37:53 -06:00
parent 60d22b0330
commit d2e48983b9
No known key found for this signature in database
GPG key ID: DE8D5010C0AAA3DC
2 changed files with 12 additions and 0 deletions

View file

@ -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 {}

View file

@ -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> {}