Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 348c58c5 authored by Matthew Maurer's avatar Matthew Maurer Committed by Automerger Merge Worker
Browse files

Merge "Implement Send trait for Binder<T>" am: a7e3f1d7 am: 5f3d7a1b

Original change: https://android-review.googlesource.com/c/platform/frameworks/native/+/1395928

Change-Id: I19c92951876cc7225c2122d7fc65bd170bcd8bd8
parents 361c9892 5f3d7a1b
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -61,7 +61,7 @@ pub trait Interface {
/// the AIDL backend, users need only implement the high-level AIDL-defined
/// interface. The AIDL compiler then generates a container struct that wraps
/// the user-defined service and implements `Remotable`.
pub trait Remotable: Sync {
pub trait Remotable: Send + Sync {
    /// The Binder interface descriptor string.
    ///
    /// This string is a unique identifier for a Binder interface, and should be
+12 −0
Original line number Diff line number Diff line
@@ -36,6 +36,18 @@ pub struct Binder<T: Remotable> {
    rust_object: *mut T,
}

/// # Safety
///
/// A `Binder<T>` is a pair of unique owning pointers to two values:
///   * a C++ ABBinder which the C++ API guarantees can be passed between threads
///   * a Rust object which implements `Remotable`; this trait requires `Send + Sync`
///
/// Both pointers are unique (never escape the `Binder<T>` object and are not copied)
/// so we can essentially treat `Binder<T>` as a box-like containing the two objects;
/// the box-like object inherits `Send` from the two inner values, similarly
/// to how `Box<T>` is `Send` if `T` is `Send`.
unsafe impl<T: Remotable> Send for Binder<T> {}

impl<T: Remotable> Binder<T> {
    /// Create a new Binder remotable object.
    ///