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

Commit 55d76349 authored by Ashutosh Agarwal's avatar Ashutosh Agarwal
Browse files

Expose RpcServer::setMaxThreads in BinderRpc Rust API.

Bug: 332776171
Test: manual
Change-Id: I6b284d93c35230f99350c77dff2b7bb7ad79dd87
parent 39fb2e6f
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -73,6 +73,17 @@ void ARpcServer_setSupportedFileDescriptorTransportModes(
        const ARpcSession_FileDescriptorTransportMode modes[],
        size_t modes_len);

// Sets the maximum number of threads that the Server will use for
// incoming client connections.
//
// This must be called before adding a client session. This corresponds
// to the number of incoming connections to RpcSession objects in the
// server, which will correspond to the number of outgoing connections
// in client RpcSession objects.
//
// If this is not specified, this will be a single-threaded server.
void ARpcServer_setMaxThreads(ARpcServer* server, size_t threads);

// Runs ARpcServer_join() in a background thread. Immediately returns.
void ARpcServer_start(ARpcServer* server);

+4 −0
Original line number Diff line number Diff line
@@ -167,6 +167,10 @@ void ARpcServer_setSupportedFileDescriptorTransportModes(
    server->setSupportedFileDescriptorTransportModes(modevec);
}

void ARpcServer_setMaxThreads(ARpcServer* handle, size_t threads) {
    handleToStrongPointer<RpcServer>(handle)->setMaxThreads(threads);
}

void ARpcServer_start(ARpcServer* handle) {
    handleToStrongPointer<RpcServer>(handle)->start();
}
+14 −0
Original line number Diff line number Diff line
@@ -147,6 +147,20 @@ impl RpcServerRef {
        }
    }

    /// Sets the max number of threads this Server uses for incoming client connections.
    ///
    /// This must be called before adding a client session. This corresponds
    /// to the number of incoming connections to RpcSession objects in the
    /// server, which will correspond to the number of outgoing connections
    /// in client RpcSession objects. Specifically this is useful for handling
    /// client-side callback connections.
    ///
    /// If this is not specified, this will be a single-threaded server.
    pub fn set_max_threads(&self, count: usize) {
        // SAFETY: RpcServerRef wraps a valid pointer to an ARpcServer.
        unsafe { binder_rpc_unstable_bindgen::ARpcServer_setMaxThreads(self.as_ptr(), count) };
    }

    /// Starts a new background thread and calls join(). Returns immediately.
    pub fn start(&self) {
        // SAFETY: RpcServerRef wraps a valid pointer to an ARpcServer.