Skip to content

Commit b9ce9ad

Browse files
author
Hideki Itakura
committed
ChangeTracker directly post change into batcher with its thread, instead of using workExecutor (pull replicator) thread.
1 parent 1ccdb88 commit b9ce9ad

1 file changed

Lines changed: 19 additions & 18 deletions

File tree

src/main/java/com/couchbase/lite/replicator/PullerInternal.java

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -702,27 +702,23 @@ public HttpClient getHttpClient() {
702702

703703
@Override
704704
public void changeTrackerReceivedChange(final Map<String, Object> change) {
705-
// this callback will be on the changetracker thread, but we need
706-
// to do the work on the replicator thread.
707-
synchronized (workExecutor) {
708-
if (!workExecutor.isShutdown()) {
709-
workExecutor.submit(new Runnable() {
710-
@Override
711-
public void run() {
712-
try {
713-
Log.d(Log.TAG_SYNC, "changeTrackerReceivedChange: %s", change);
714-
processChangeTrackerChange(change);
715-
} catch (Exception e) {
716-
Log.e(Log.TAG_SYNC, "Error processChangeTrackerChange(): %s", e);
717-
e.printStackTrace();
718-
throw new RuntimeException(e);
719-
}
720-
}
721-
});
722-
}
705+
try {
706+
Log.d(Log.TAG_SYNC, "changeTrackerReceivedChange: %s", change);
707+
processChangeTrackerChange(change);
708+
} catch (Exception e) {
709+
Log.e(Log.TAG_SYNC, "Error processChangeTrackerChange(): %s", e);
710+
e.printStackTrace();
711+
throw new RuntimeException(e);
723712
}
724713
}
725714

715+
/**
716+
* in CBL_Puller.m
717+
* - (void) changeTrackerReceivedSequence: (id)remoteSequenceID
718+
* docID: (NSString*)docID
719+
* revIDs: (NSArray*)revIDs
720+
* deleted: (BOOL)deleted
721+
*/
726722
protected void processChangeTrackerChange(final Map<String, Object> change)
727723
{
728724
String lastSequence = change.get("seq").toString();
@@ -744,6 +740,11 @@ protected void processChangeTrackerChange(final Map<String, Object> change)
744740
}
745741
PulledRevision rev = new PulledRevision(docID, revID, deleted);
746742
rev.setRemoteSequenceID(lastSequence);
743+
744+
// TODO: Need to do conflict check?
745+
// if (revIDs.count > 1)
746+
// rev.conflicted = true;
747+
747748
Log.d(Log.TAG_SYNC, "%s: adding rev to inbox %s", this, rev);
748749

749750
Log.v(Log.TAG_SYNC, "%s: changeTrackerReceivedChange() incrementing changesCount by 1", this);

0 commit comments

Comments
 (0)