Merge "Removing number of threads used in background execution to prevent system thrashing" into sc-dev
This commit is contained in:
commit
194dcc0fd3
|
@ -16,7 +16,6 @@
|
|||
package com.android.quickstep;
|
||||
|
||||
import static com.android.launcher3.util.Executors.MAIN_EXECUTOR;
|
||||
import static com.android.launcher3.util.Executors.THREAD_POOL_EXECUTOR;
|
||||
import static com.android.launcher3.util.Executors.UI_HELPER_EXECUTOR;
|
||||
|
||||
import android.view.SurfaceControl;
|
||||
|
@ -102,7 +101,7 @@ public class RecentsAnimationController {
|
|||
*/
|
||||
@UiThread
|
||||
public void removeTaskTarget(@NonNull RemoteAnimationTargetCompat target) {
|
||||
THREAD_POOL_EXECUTOR.execute(() -> mController.removeTask(target.taskId));
|
||||
UI_HELPER_EXECUTOR.execute(() -> mController.removeTask(target.taskId));
|
||||
}
|
||||
|
||||
@UiThread
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
*/
|
||||
package com.android.launcher3.model;
|
||||
|
||||
import static com.android.launcher3.util.Executors.createAndStartNewForegroundLooper;
|
||||
import static com.android.launcher3.util.Executors.createAndStartNewLooper;
|
||||
import static com.android.launcher3.util.LauncherModelHelper.TEST_PACKAGE;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
@ -74,7 +74,7 @@ public class ModelMultiCallbacksTest {
|
|||
|
||||
// Since robolectric tests run on main thread, we run the loader-UI calls on a temp thread,
|
||||
// so that we can wait appropriately for the loader to complete.
|
||||
mTempMainExecutor = new LooperExecutor(createAndStartNewForegroundLooper("tempMain"));
|
||||
mTempMainExecutor = new LooperExecutor(createAndStartNewLooper("tempMain"));
|
||||
ShadowLooperExecutor sle = Shadow.extract(Executors.MAIN_EXECUTOR);
|
||||
sle.setHandler(mTempMainExecutor.getHandler());
|
||||
}
|
||||
|
|
|
@ -30,18 +30,15 @@ import java.util.concurrent.atomic.AtomicInteger;
|
|||
*/
|
||||
public class Executors {
|
||||
|
||||
// These values are same as that in {@link AsyncTask}.
|
||||
private static final int CPU_COUNT = Runtime.getRuntime().availableProcessors();
|
||||
private static final int CORE_POOL_SIZE = CPU_COUNT + 1;
|
||||
private static final int MAXIMUM_POOL_SIZE = CPU_COUNT * 2 + 1;
|
||||
private static final int POOL_SIZE =
|
||||
Math.max(Runtime.getRuntime().availableProcessors(), 2);
|
||||
private static final int KEEP_ALIVE = 1;
|
||||
|
||||
/**
|
||||
* An {@link ThreadPoolExecutor} to be used with async task with no limit on the queue size.
|
||||
*/
|
||||
public static final ThreadPoolExecutor THREAD_POOL_EXECUTOR = new ThreadPoolExecutor(
|
||||
CORE_POOL_SIZE, MAXIMUM_POOL_SIZE, KEEP_ALIVE,
|
||||
TimeUnit.SECONDS, new LinkedBlockingQueue<>());
|
||||
POOL_SIZE, POOL_SIZE, KEEP_ALIVE, TimeUnit.SECONDS, new LinkedBlockingQueue<>());
|
||||
|
||||
/**
|
||||
* Returns the executor for running tasks on the main thread.
|
||||
|
@ -53,7 +50,8 @@ public class Executors {
|
|||
* A background executor for using time sensitive actions where user is waiting for response.
|
||||
*/
|
||||
public static final LooperExecutor UI_HELPER_EXECUTOR =
|
||||
new LooperExecutor(createAndStartNewForegroundLooper("UiThreadHelper"));
|
||||
new LooperExecutor(
|
||||
createAndStartNewLooper("UiThreadHelper", Process.THREAD_PRIORITY_FOREGROUND));
|
||||
|
||||
/**
|
||||
* Utility method to get a started handler thread statically
|
||||
|
@ -71,15 +69,6 @@ public class Executors {
|
|||
return thread.getLooper();
|
||||
}
|
||||
|
||||
/**
|
||||
* Similar to {@link #createAndStartNewLooper(String)}, but starts the thread with
|
||||
* foreground priority.
|
||||
* Think before using
|
||||
*/
|
||||
public static Looper createAndStartNewForegroundLooper(String name) {
|
||||
return createAndStartNewLooper(name, Process.THREAD_PRIORITY_FOREGROUND);
|
||||
}
|
||||
|
||||
/**
|
||||
* Executor used for running Launcher model related tasks (eg loading icons or updated db)
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue