Prepare operation partitioning

This commit is contained in:
M66B 2020-01-25 12:38:38 +01:00
parent 37d4b218b7
commit 544d4dfd61
2 changed files with 9 additions and 9 deletions

View File

@ -125,7 +125,7 @@ class Core {
static void processOperations(
Context context,
EntityAccount account, EntityFolder folder,
EntityAccount account, EntityFolder folder, List<TupleOperationEx> ops,
Store istore, Folder ifolder,
State state)
throws MessagingException, JSONException, IOException {
@ -133,10 +133,9 @@ class Core {
Log.i(folder.name + " start process");
DB db = DB.getInstance(context);
List<TupleOperationEx> ops = db.operation().getOperations(folder.id);
List<Long> processed = new ArrayList<>();
Log.i(folder.name + " pending operations=" + ops.size());
Log.i(folder.name + " executing operations=" + ops.size());
for (int i = 0; i < ops.size() && state.isRunning() && state.isRecoverable(); i++) {
EntityOperation op = ops.get(i);
if (processed.contains(op.id)) {

View File

@ -1109,18 +1109,18 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
PowerManager.PARTIAL_WAKE_LOCK, BuildConfig.APPLICATION_ID + ":folder." + folder.id);
@Override
public void onChanged(final List<TupleOperationEx> operations) {
boolean process = false;
public void onChanged(final List<TupleOperationEx> _operations) {
List<Long> ops = new ArrayList<>();
for (EntityOperation op : operations) {
List<TupleOperationEx> operations = new ArrayList<>();
for (TupleOperationEx op : _operations) {
if (!handling.contains(op.id))
process = true;
operations.add(op);
ops.add(op.id);
}
handling = ops;
if (handling.size() > 0 && process) {
Log.i(folder.name + " operations=" + operations.size() +
if (operations.size() > 0 ) {
Log.i(folder.name + " queuing operations=" + operations.size() +
" init=" + folder.initialize + " poll=" + folder.poll);
executor.submit(new Helper.PriorityRunnable(operations.get(0).priority) {
@ -1156,6 +1156,7 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
Core.processOperations(ServiceSynchronize.this,
account, folder,
operations,
iservice.getStore(), ifolder,
state);