Loading services/appfunctions/java/com/android/server/appfunctions/AppFunctionExecutors.java +2 −1 Original line number Diff line number Diff line Loading @@ -31,7 +31,8 @@ public final class AppFunctionExecutors { /* maxConcurrency= */ Runtime.getRuntime().availableProcessors(), /* keepAliveTime= */ 0L, /* unit= */ TimeUnit.SECONDS, /* workQueue= */ new LinkedBlockingQueue<>()); /* workQueue= */ new LinkedBlockingQueue<>(), new NamedThreadFactory("AppFunctionExecutors")); private AppFunctionExecutors() {} } services/appfunctions/java/com/android/server/appfunctions/MetadataSyncAdapter.java +3 −1 Original line number Diff line number Diff line Loading @@ -84,7 +84,9 @@ public class MetadataSyncAdapter { @NonNull PackageManager packageManager, @NonNull AppSearchManager appSearchManager) { mPackageManager = Objects.requireNonNull(packageManager); mAppSearchManager = Objects.requireNonNull(appSearchManager); mExecutor = Executors.newSingleThreadExecutor(); mExecutor = Executors.newSingleThreadExecutor( new NamedThreadFactory("AppFunctionSyncExecutors")); } /** Loading services/appfunctions/java/com/android/server/appfunctions/NamedThreadFactory.java 0 → 100644 +40 −0 Original line number Diff line number Diff line /* * Copyright (C) 2024 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.server.appfunctions; import java.util.concurrent.Executors; import java.util.concurrent.ThreadFactory; import java.util.concurrent.atomic.AtomicInteger; /** A {@link ThreadFactory} that creates threads with a given base name. */ public class NamedThreadFactory implements ThreadFactory { private final ThreadFactory mDefaultThreadFactory; private final String mBaseName; private final AtomicInteger mCount = new AtomicInteger(0); public NamedThreadFactory(final String baseName) { mDefaultThreadFactory = Executors.defaultThreadFactory(); mBaseName = baseName; } @Override public Thread newThread(Runnable runnable) { final Thread thread = mDefaultThreadFactory.newThread(runnable); thread.setName(mBaseName + "-" + mCount.getAndIncrement()); return thread; } } Loading
services/appfunctions/java/com/android/server/appfunctions/AppFunctionExecutors.java +2 −1 Original line number Diff line number Diff line Loading @@ -31,7 +31,8 @@ public final class AppFunctionExecutors { /* maxConcurrency= */ Runtime.getRuntime().availableProcessors(), /* keepAliveTime= */ 0L, /* unit= */ TimeUnit.SECONDS, /* workQueue= */ new LinkedBlockingQueue<>()); /* workQueue= */ new LinkedBlockingQueue<>(), new NamedThreadFactory("AppFunctionExecutors")); private AppFunctionExecutors() {} }
services/appfunctions/java/com/android/server/appfunctions/MetadataSyncAdapter.java +3 −1 Original line number Diff line number Diff line Loading @@ -84,7 +84,9 @@ public class MetadataSyncAdapter { @NonNull PackageManager packageManager, @NonNull AppSearchManager appSearchManager) { mPackageManager = Objects.requireNonNull(packageManager); mAppSearchManager = Objects.requireNonNull(appSearchManager); mExecutor = Executors.newSingleThreadExecutor(); mExecutor = Executors.newSingleThreadExecutor( new NamedThreadFactory("AppFunctionSyncExecutors")); } /** Loading
services/appfunctions/java/com/android/server/appfunctions/NamedThreadFactory.java 0 → 100644 +40 −0 Original line number Diff line number Diff line /* * Copyright (C) 2024 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.server.appfunctions; import java.util.concurrent.Executors; import java.util.concurrent.ThreadFactory; import java.util.concurrent.atomic.AtomicInteger; /** A {@link ThreadFactory} that creates threads with a given base name. */ public class NamedThreadFactory implements ThreadFactory { private final ThreadFactory mDefaultThreadFactory; private final String mBaseName; private final AtomicInteger mCount = new AtomicInteger(0); public NamedThreadFactory(final String baseName) { mDefaultThreadFactory = Executors.defaultThreadFactory(); mBaseName = baseName; } @Override public Thread newThread(Runnable runnable) { final Thread thread = mDefaultThreadFactory.newThread(runnable); thread.setName(mBaseName + "-" + mCount.getAndIncrement()); return thread; } }