Skip main thread test in ThreadSafeProgressMonitor
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: I6cb9382d71b4cb3f8e8981c7ac382da25304dfcb
This commit is contained in:
parent
66192817cd
commit
d01fe32795
|
@ -104,9 +104,11 @@ public void testMethodsOkOnMainThread() {
|
|||
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 @@ private void doUpdates() {
|
|||
}
|
||||
|
||||
public void update(int completed) {
|
||||
int old = pendingUpdates.getAndAdd(completed);
|
||||
if (isMainThread())
|
||||
doUpdates();
|
||||
else if (old == 0)
|
||||
if (0 == pendingUpdates.getAndAdd(completed))
|
||||
process.release();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue