fix(napi): impl send + sync for ThreadsafeFunction (#1622)

This commit is contained in:
LongYinan 2023-06-14 15:24:01 +08:00 committed by GitHub
parent 7e2b75cc33
commit 53cd1bc904
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -235,6 +235,9 @@ pub struct ThreadsafeFunction<T: 'static, ES: ErrorStrategy::T = ErrorStrategy::
_phantom: PhantomData<(T, ES)>, _phantom: PhantomData<(T, ES)>,
} }
unsafe impl<T: 'static, ES: ErrorStrategy::T> Send for ThreadsafeFunction<T, ES> {}
unsafe impl<T: 'static, ES: ErrorStrategy::T> Sync for ThreadsafeFunction<T, ES> {}
impl<T: 'static, ES: ErrorStrategy::T> Clone for ThreadsafeFunction<T, ES> { impl<T: 'static, ES: ErrorStrategy::T> Clone for ThreadsafeFunction<T, ES> {
fn clone(&self) -> Self { fn clone(&self) -> Self {
self.handle.with_read_aborted(|aborted| { self.handle.with_read_aborted(|aborted| {