From 5b4ae73541f103315b9486299717ed6e491e0067 Mon Sep 17 00:00:00 2001 From: Micah Johnston Date: Tue, 30 Apr 2024 17:30:55 -0500 Subject: [PATCH] add Send and Sync impls for ComPtr and ComRef (#14) ComPtr and ComRef currently do not implement Send or Sync, regardless of what T is, since they contain NonNull fields. This is unnecessarily restrictive. Add Send and Sync impls for ComPtr and ComRef with the same bounds as the Send and Sync impls for Arc in the standard library. --- com-scrape-types/src/ptr.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/com-scrape-types/src/ptr.rs b/com-scrape-types/src/ptr.rs index 8bfd72afc..b86c217ba 100644 --- a/com-scrape-types/src/ptr.rs +++ b/com-scrape-types/src/ptr.rs @@ -69,6 +69,10 @@ impl<'a, I: Interface> Clone for ComRef<'a, I> { } } +unsafe impl<'a, I: Interface> Send for ComRef<'a, I> where I: Sync + Send {} + +unsafe impl<'a, I: Interface> Sync for ComRef<'a, I> where I: Sync + Send {} + impl<'a, I: Interface> ComRef<'a, I> { /// Gets the wrapped interface pointer. /// @@ -192,6 +196,10 @@ impl Clone for ComPtr { } } +unsafe impl Send for ComPtr where I: Sync + Send {} + +unsafe impl Sync for ComPtr where I: Sync + Send {} + impl Drop for ComPtr { #[inline] fn drop(&mut self) {