Use dedicate operation executor

pull/212/head
M66B 3 years ago
parent fdaa270b80
commit a7c79ffc0c

@ -260,9 +260,6 @@ public class Helper {
private static ExecutorService sMediaExecutor = null; private static ExecutorService sMediaExecutor = null;
private static ExecutorService sDownloadExecutor = null; private static ExecutorService sDownloadExecutor = null;
private static int sOperationIndex = 0;
private static final ExecutorService[] sOperationExecutor = new ExecutorService[OPERATION_WORKERS];
static ExecutorService getSerialExecutor() { static ExecutorService getSerialExecutor() {
if (sSerialExecutor == null) if (sSerialExecutor == null)
sSerialExecutor = getBackgroundExecutor(1, "serial"); sSerialExecutor = getBackgroundExecutor(1, "serial");
@ -293,16 +290,6 @@ public class Helper {
return sDownloadExecutor; 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) { static ExecutorService getBackgroundExecutor(int threads, final String name) {
ThreadFactory factory = new ThreadFactory() { ThreadFactory factory = new ThreadFactory() {
private final AtomicInteger threadId = new AtomicInteger(); private final AtomicInteger threadId = new AtomicInteger();

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

Loading…
Cancel
Save