From 51d76c818da841f2b35dce8dd2ba3f197a683e2a Mon Sep 17 00:00:00 2001 From: Matthew Maurer Date: Mon, 4 Apr 2022 14:27:01 -0700 Subject: rust: Mark DeathRecipient Send and Sync Test: mm Change-Id: Id39b32764cf9e542974fcdcd9faf00715cce17c2 --- libs/binder/rust/src/proxy.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/libs/binder/rust/src/proxy.rs b/libs/binder/rust/src/proxy.rs index e3e47305d4..4df557bee0 100644 --- a/libs/binder/rust/src/proxy.rs +++ b/libs/binder/rust/src/proxy.rs @@ -575,6 +575,20 @@ struct DeathRecipientVtable { cookie_decr_refcount: unsafe extern "C" fn(*mut c_void), } +/// # Safety +/// +/// A `DeathRecipient` is a wrapper around `AIBinder_DeathRecipient` and a pointer +/// to a `Fn` which is `Sync` and `Send` (the cookie field). As +/// `AIBinder_DeathRecipient` is threadsafe, this structure is too. +unsafe impl Send for DeathRecipient {} + +/// # Safety +/// +/// A `DeathRecipient` is a wrapper around `AIBinder_DeathRecipient` and a pointer +/// to a `Fn` which is `Sync` and `Send` (the cookie field). As +/// `AIBinder_DeathRecipient` is threadsafe, this structure is too. +unsafe impl Sync for DeathRecipient {} + impl DeathRecipient { /// Create a new death recipient that will call the given callback when its /// associated object dies. -- cgit v1.2.3-59-g8ed1b