Skip to content

Commit

Permalink
add Send and Sync impls for ComPtr and ComRef (#14)
Browse files Browse the repository at this point in the history
ComPtr<T> and ComRef<T> 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.
  • Loading branch information
micahrj authored Apr 30, 2024
1 parent 2782a9f commit 5b4ae73
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions com-scrape-types/src/ptr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
///
Expand Down Expand Up @@ -192,6 +196,10 @@ impl<I: Interface> Clone for ComPtr<I> {
}
}

unsafe impl<I: Interface> Send for ComPtr<I> where I: Sync + Send {}

unsafe impl<I: Interface> Sync for ComPtr<I> where I: Sync + Send {}

impl<I: Interface> Drop for ComPtr<I> {
#[inline]
fn drop(&mut self) {
Expand Down

0 comments on commit 5b4ae73

Please sign in to comment.