Simplified operation batch logic

This commit is contained in:
M66B
2021-09-16 10:43:14 +02:00
parent d3048fe62a
commit bd98f62d7b
2 changed files with 18 additions and 88 deletions

View File

@@ -24,9 +24,7 @@ import static android.os.Process.THREAD_PRIORITY_BACKGROUND;
import android.app.AlarmManager;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.appwidget.AppWidgetManager;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
@@ -1861,14 +1859,14 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
" operations=" + partitions.get(key).size());
}
final long sequence = state.getSequence(folder.id, key.getPriority());
final long serial = state.getSerial();
Map<String, String> crumb = new HashMap<>();
crumb.put("account", folder.account == null ? null : Long.toString(folder.account));
crumb.put("folder", folder.name + "/" + folder.type + ":" + folder.id);
crumb.put("partition", key.toString());
crumb.put("operations", Integer.toString(partitions.get(key).size()));
crumb.put("sequence", Long.toString(sequence));
crumb.put("serial", Long.toString(serial));
Log.breadcrumb("Queuing", crumb);
executor.submit(new Helper.PriorityRunnable(key.getPriority(), key.getOrder()) {
@@ -1886,7 +1884,7 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
Log.i(folder.name +
" executing partition=" + key +
" sequence=" + sequence +
" serial=" + serial +
" operations=" + partition.size());
Map<String, String> crumb = new HashMap<>();
@@ -1894,7 +1892,7 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
crumb.put("folder", folder.name + "/" + folder.type + ":" + folder.id);
crumb.put("partition", key.toString());
crumb.put("operations", Integer.toString(partition.size()));
crumb.put("sequence", Long.toString(sequence));
crumb.put("serial", Long.toString(serial));
Log.breadcrumb("Executing", crumb);
// Get folder
@@ -1946,7 +1944,7 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
account, folder,
partition,
iservice.getStore(), ifolder,
state, key.getPriority(), sequence);
state, serial);
} catch (Throwable ex) {
Log.e(folder.name, ex);
@@ -2186,7 +2184,7 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
// Stop executing operations
Log.i(account.name + " stop executing operations");
state.resetBatches();
state.nextSerial();
((ThreadPoolExecutor) executor).getQueue().clear();
// Close store