Threads launching threads

pull/14/head
Sam Bosley 13 years ago
parent cb95621ddc
commit 02d6d30d83

@ -142,10 +142,13 @@ public final class ActFmSyncService {
taskPushThreads.incrementAndGet();
waitUntilEmpty.close();
// sleep so metadata associated with task is saved
AndroidUtilities.sleepDeep(1000L);
pushTaskOnSave(model, setValues);
if (taskPushThreads.decrementAndGet() == 0) {
waitUntilEmpty.open();
try {
AndroidUtilities.sleepDeep(1000L);
pushTaskOnSave(model, setValues);
} finally {
if (taskPushThreads.decrementAndGet() == 0) {
waitUntilEmpty.open();
}
}
}
}).start();

@ -106,22 +106,26 @@ public class ActFmSyncV2Provider extends SyncV2Provider {
// --- synchronize active tasks
@Override
public void synchronizeActiveTasks(boolean manual,
public void synchronizeActiveTasks(final boolean manual,
final SyncResultCallback callback) {
callback.started();
callback.incrementMax(100);
new Thread(new Runnable() {
public void run() {
callback.started();
callback.incrementMax(100);
final AtomicInteger finisher = new AtomicInteger(2);
final AtomicInteger finisher = new AtomicInteger(2);
actFmPreferenceService.recordSyncStart();
actFmPreferenceService.recordSyncStart();
startTagFetcher(callback, finisher);
startTagFetcher(callback, finisher);
actFmSyncService.waitUntilEmpty();
startTaskFetcher(manual, callback, finisher);
actFmSyncService.waitUntilEmpty();
startTaskFetcher(manual, callback, finisher);
callback.incrementProgress(50);
callback.incrementProgress(50);
}
}).start();
}
/** fetch changes to tags */
@ -239,29 +243,33 @@ public class ActFmSyncV2Provider extends SyncV2Provider {
// --- synchronize list
@Override
public void synchronizeList(Object list, boolean manual,
public void synchronizeList(Object list, final boolean manual,
final SyncResultCallback callback) {
if(!(list instanceof TagData))
return;
TagData tagData = (TagData) list;
final TagData tagData = (TagData) list;
final boolean noRemoteId = tagData.getValue(TagData.REMOTE_ID) == 0;
callback.started();
callback.incrementMax(100);
new Thread(new Runnable() {
public void run() {
callback.started();
callback.incrementMax(100);
final AtomicInteger finisher = new AtomicInteger(3);
final AtomicInteger finisher = new AtomicInteger(3);
fetchTagData(tagData, noRemoteId, manual, callback, finisher);
fetchTagData(tagData, noRemoteId, manual, callback, finisher);
if(!noRemoteId) {
actFmSyncService.waitUntilEmpty();
fetchTasksForTag(tagData, manual, callback, finisher);
fetchUpdatesForTag(tagData, manual, callback, finisher);
}
if(!noRemoteId) {
actFmSyncService.waitUntilEmpty();
fetchTasksForTag(tagData, manual, callback, finisher);
fetchUpdatesForTag(tagData, manual, callback, finisher);
}
callback.incrementProgress(50);
callback.incrementProgress(50);
}
}).start();
}
private void fetchTagData(final TagData tagData, final boolean noRemoteId,

Loading…
Cancel
Save