update(int) is only invoked from a worker thread, in JGit's case this is DeltaTask. The Javadoc of TSPM suggests update should only ever be used by a worker thread. Skip the main thread check, saving some cycles on each run of the progress monitor. Change-Id: I6cb9382d71b4cb3f8e8981c7ac382da25304dfcbtags/v3.0.0.201305080800-m7
@@ -104,9 +104,11 @@ public class ThreadSafeProgressMonitorTest { | |||
assertEquals(42, mock.value); | |||
pm.update(1); | |||
pm.pollForUpdates(); | |||
assertEquals(43, mock.value); | |||
pm.update(2); | |||
pm.pollForUpdates(); | |||
assertEquals(45, mock.value); | |||
pm.endTask(); |
@@ -157,10 +157,7 @@ public class ThreadSafeProgressMonitor implements ProgressMonitor { | |||
} | |||
public void update(int completed) { | |||
int old = pendingUpdates.getAndAdd(completed); | |||
if (isMainThread()) | |||
doUpdates(); | |||
else if (old == 0) | |||
if (0 == pendingUpdates.getAndAdd(completed)) | |||
process.release(); | |||
} | |||