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

Commit a9c4d801 authored by Steven Moreland's avatar Steven Moreland
Browse files

libbinder*: Provide warning of library threadpool woes.

Libraries messing with global threadpools = no no.

Change-Id: I02ee0646c23fc13279b6cf2a0ffe181160bf73bb
Bug: 260920753
Test: N/A
parent ebe862d8
Loading
Loading
Loading
Loading
+2 −0
Original line number Original line Diff line number Diff line
@@ -141,11 +141,13 @@ public:
            void                restoreCallingIdentity(int64_t token);
            void                restoreCallingIdentity(int64_t token);
            bool hasExplicitIdentity();
            bool hasExplicitIdentity();


            // For main functions - dangerous for libraries to use
            status_t            setupPolling(int* fd);
            status_t            setupPolling(int* fd);
            status_t            handlePolledCommands();
            status_t            handlePolledCommands();
            void                flushCommands();
            void                flushCommands();
            bool                flushIfNeeded();
            bool                flushIfNeeded();


            // For main functions - dangerous for libraries to use
            void                joinThreadPool(bool isMain = true);
            void                joinThreadPool(bool isMain = true);
            
            
            // Stop the local process.
            // Stop the local process.
+3 −0
Original line number Original line Diff line number Diff line
@@ -50,6 +50,7 @@ public:


    sp<IBinder> getContextObject(const sp<IBinder>& caller);
    sp<IBinder> getContextObject(const sp<IBinder>& caller);


    // For main functions - dangerous for libraries to use
    void startThreadPool();
    void startThreadPool();


    bool becomeContextManager();
    bool becomeContextManager();
@@ -57,8 +58,10 @@ public:
    sp<IBinder> getStrongProxyForHandle(int32_t handle);
    sp<IBinder> getStrongProxyForHandle(int32_t handle);
    void expungeHandle(int32_t handle, IBinder* binder);
    void expungeHandle(int32_t handle, IBinder* binder);


    // TODO: deprecate.
    void spawnPooledThread(bool isMain);
    void spawnPooledThread(bool isMain);


    // For main functions - dangerous for libraries to use
    status_t setThreadPoolMaxThreadCount(size_t maxThreads);
    status_t setThreadPoolMaxThreadCount(size_t maxThreads);
    status_t enableOnewaySpamDetection(bool enable);
    status_t enableOnewaySpamDetection(bool enable);
    void giveThreadPoolName();
    void giveThreadPoolName();
+9 −0
Original line number Original line Diff line number Diff line
@@ -28,17 +28,26 @@ __BEGIN_DECLS
 *
 *
 * When using this, it is expected that ABinderProcess_setupPolling and
 * When using this, it is expected that ABinderProcess_setupPolling and
 * ABinderProcess_handlePolledCommands are not used.
 * ABinderProcess_handlePolledCommands are not used.
 *
 * Do not use this from a library. Apps setup their own threadpools, and otherwise, the main
 * function should be responsible for configuring the threadpool for the entire application.
 */
 */
void ABinderProcess_startThreadPool();
void ABinderProcess_startThreadPool();
/**
/**
 * This sets the maximum number of threads that can be started in the threadpool. By default, after
 * This 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 additional times, it will only prevent
 * startThreadPool is called, this is 15. If it is called additional times, it will only prevent
 * the kernel from starting new threads and will not delete already existing threads.
 * the kernel from starting new threads and will not delete already existing threads.
 *
 * Do not use this from a library. Apps setup their own threadpools, and otherwise, the main
 * function should be responsible for configuring the threadpool for the entire application.
 */
 */
bool ABinderProcess_setThreadPoolMaxThreadCount(uint32_t numThreads);
bool ABinderProcess_setThreadPoolMaxThreadCount(uint32_t numThreads);
/**
/**
 * This adds the current thread to the threadpool. This may cause the threadpool to exceed the
 * This adds the current thread to the threadpool. This may cause the threadpool to exceed the
 * maximum size.
 * maximum size.
 *
 * Do not use this from a library. Apps setup their own threadpools, and otherwise, the main
 * function should be responsible for configuring the threadpool for the entire application.
 */
 */
void ABinderProcess_joinThreadPool();
void ABinderProcess_joinThreadPool();