summaryrefslogtreecommitdiff
path: root/services/appfunctions/java
diff options
context:
space:
mode:
author Oluwarotimi Adesina <oadesina@google.com> 2024-11-12 17:08:21 +0000
committer Oluwarotimi Adesina <oadesina@google.com> 2024-11-12 17:34:11 +0000
commit53cf0949310e568f75a0f12ac80b91f69c271a18 (patch)
tree4788c8209714b106d9ab778248c758343135c7f4 /services/appfunctions/java
parent1af6bb4f4b483c73205912d0cf3ed33299431410 (diff)
Add idletimeout to AF exe pool
Flag: android.app.appfunctions.flags.enable_app_function_manager Test: existing CTS Bug: 371050337 Change-Id: Ic0c2e8a4835724d52623ee555c7bf4fe9385bed3
Diffstat (limited to 'services/appfunctions/java')
-rw-r--r--services/appfunctions/java/com/android/server/appfunctions/AppFunctionExecutors.java15
1 files changed, 10 insertions, 5 deletions
diff --git a/services/appfunctions/java/com/android/server/appfunctions/AppFunctionExecutors.java b/services/appfunctions/java/com/android/server/appfunctions/AppFunctionExecutors.java
index 44ae1d1fbbbf..81e83b563945 100644
--- a/services/appfunctions/java/com/android/server/appfunctions/AppFunctionExecutors.java
+++ b/services/appfunctions/java/com/android/server/appfunctions/AppFunctionExecutors.java
@@ -16,7 +16,6 @@
package com.android.server.appfunctions;
-import java.util.concurrent.Executor;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
@@ -24,15 +23,21 @@ import java.util.concurrent.TimeUnit;
/** Executors for App function operations. */
public final class AppFunctionExecutors {
+ static final int sConcurrency = Runtime.getRuntime().availableProcessors();
+
/** Executor for operations that do not need to block. */
- public static final Executor THREAD_POOL_EXECUTOR =
+ public static final ThreadPoolExecutor THREAD_POOL_EXECUTOR =
new ThreadPoolExecutor(
- /* corePoolSize= */ Runtime.getRuntime().availableProcessors(),
- /* maxConcurrency= */ Runtime.getRuntime().availableProcessors(),
- /* keepAliveTime= */ 0L,
+ /* corePoolSize= */ sConcurrency,
+ /* maxConcurrency= */ sConcurrency,
+ /* keepAliveTime= */ 1L,
/* unit= */ TimeUnit.SECONDS,
/* workQueue= */ new LinkedBlockingQueue<>(),
new NamedThreadFactory("AppFunctionExecutors"));
+ static {
+ THREAD_POOL_EXECUTOR.allowCoreThreadTimeOut(true);
+ }
+
private AppFunctionExecutors() {}
}