Use dedicate operation executor

This commit is contained in:
M66B 2023-02-02 07:45:24 +01:00
parent fdaa270b80
commit a7c79ffc0c
2 changed files with 1 additions and 14 deletions

View File

@ -260,9 +260,6 @@ public class Helper {
private static ExecutorService sMediaExecutor = null;
private static ExecutorService sDownloadExecutor = null;
private static int sOperationIndex = 0;
private static final ExecutorService[] sOperationExecutor = new ExecutorService[OPERATION_WORKERS];
static ExecutorService getSerialExecutor() {
if (sSerialExecutor == null)
sSerialExecutor = getBackgroundExecutor(1, "serial");
@ -293,16 +290,6 @@ public class Helper {
return sDownloadExecutor;
}
static ExecutorService getOperationExecutor() {
synchronized (sOperationExecutor) {
if (sOperationExecutor[sOperationIndex] == null)
sOperationExecutor[sOperationIndex] = getBackgroundExecutor(1, "operation");
ExecutorService result = sOperationExecutor[sOperationIndex];
sOperationIndex = (sOperationIndex + 1) % sOperationExecutor.length;
return result;
}
}
static ExecutorService getBackgroundExecutor(int threads, final String name) {
ThreadFactory factory = new ThreadFactory() {
private final AtomicInteger threadId = new AtomicInteger();

View File

@ -1550,7 +1550,7 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
Log.i(account.name + " run thread=" + currentThread);
final ObjectHolder<TwoStateOwner> cowner = new ObjectHolder<>();
final ExecutorService executor = Helper.getOperationExecutor();
final ExecutorService executor = Helper.getBackgroundExecutor(1, "operation." + account.id);
// Debug
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);