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

Commit 617e3aca authored by Steven Moreland's avatar Steven Moreland Committed by Automerger Merge Worker
Browse files

Merge "Improve Rust documentation of Binder thread pool." am: 7ed4fc1d am:...

Merge "Improve Rust documentation of Binder thread pool." am: 7ed4fc1d am: b09fd752 am: ced50cdf am: b66a46e8 am: 476375d4

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



Change-Id: I97e1f04e5cc04d1b20e43c7ceac9740e928c7e85
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents 7c6f3158 476375d4
Loading
Loading
Loading
Loading
+8 −1
Original line number Original line Diff line number Diff line
@@ -260,7 +260,14 @@ pub trait IBinder {
    /// Trying to use this function on a local binder will result in an
    /// Trying to use this function on a local binder will result in an
    /// INVALID_OPERATION code being returned and nothing happening.
    /// INVALID_OPERATION code being returned and nothing happening.
    ///
    ///
    /// This link always holds a weak reference to its recipient.
    /// This link only holds a weak reference to its recipient. If the
    /// `DeathRecipient` is dropped then it will be unlinked.
    ///
    /// Note that the notifications won't work if you don't first start at least
    /// one Binder thread by calling
    /// [`ProcessState::start_thread_pool`](crate::ProcessState::start_thread_pool)
    /// or
    /// [`ProcessState::join_thread_pool`](crate::ProcessState::join_thread_pool).
    fn link_to_death(&mut self, recipient: &mut DeathRecipient) -> Result<()>;
    fn link_to_death(&mut self, recipient: &mut DeathRecipient) -> Result<()>;


    /// Remove a previously registered death notification.
    /// Remove a previously registered death notification.
+22 −9
Original line number Original line Diff line number Diff line
@@ -22,10 +22,18 @@ use libc::{pid_t, uid_t};
pub struct ProcessState;
pub struct ProcessState;


impl ProcessState {
impl ProcessState {
    /// Start the Binder IPC thread pool
    /// Starts the Binder IPC thread pool.
    ///
    ///
    /// Starts 1 thread, plus allows the kernel to lazily start up to 'num_threads'
    /// Starts 1 thread, plus allows the kernel to lazily start up to
    /// additional threads as specified by set_thread_pool_max_thread_count.
    /// `num_threads` additional threads as specified by
    /// [`set_thread_pool_max_thread_count`](Self::set_thread_pool_max_thread_count).
    ///
    /// This should be done before creating any Binder client or server. If
    /// neither this nor [`join_thread_pool`](Self::join_thread_pool) are
    /// called, then some things (such as callbacks and
    /// [`IBinder::link_to_death`](crate::IBinder::link_to_death)) will silently
    /// not work: the callbacks will be queued but never called as there is no
    /// thread to call them on.
    pub fn start_thread_pool() {
    pub fn start_thread_pool() {
        unsafe {
        unsafe {
            // Safety: Safe FFI
            // Safety: Safe FFI
@@ -33,10 +41,12 @@ impl ProcessState {
        }
        }
    }
    }


    /// Set the maximum number of threads that can be started in the threadpool.
    /// Sets the maximum number of threads that can be started in the
    /// threadpool.
    ///
    ///
    /// By default, after startThreadPool is called, this is 15. If it is called
    /// By default, after [`start_thread_pool`](Self::start_thread_pool) is
    /// additional times, the thread pool size can only be increased.
    /// called, this is 15. If it is called additional times, the thread pool
    /// size can only be increased.
    pub fn set_thread_pool_max_thread_count(num_threads: u32) {
    pub fn set_thread_pool_max_thread_count(num_threads: u32) {
        unsafe {
        unsafe {
            // Safety: Safe FFI
            // Safety: Safe FFI
@@ -44,10 +54,13 @@ impl ProcessState {
        }
        }
    }
    }


    /// Block on the Binder IPC thread pool
    /// Blocks on the Binder IPC thread pool by adding the current thread to the
    /// pool.
    ///
    ///
    /// This adds additional threads in addition to what is created by
    /// Note that this adds the current thread in addition to those that are
    /// set_thread_pool_max_thread_count and start_thread_pool.
    /// created by
    /// [`set_thread_pool_max_thread_count`](Self::set_thread_pool_max_thread_count)
    /// and [`start_thread_pool`](Self::start_thread_pool).
    pub fn join_thread_pool() {
    pub fn join_thread_pool() {
        unsafe {
        unsafe {
            // Safety: Safe FFI
            // Safety: Safe FFI