diff options
author | Shawn O. Pearce <spearce@spearce.org> | 2011-02-28 19:34:06 -0800 |
---|---|---|
committer | Shawn O. Pearce <spearce@spearce.org> | 2011-02-28 19:36:56 -0800 |
commit | 68ab451d3907e38f7c259ef52a9c3c6a6ee42ead (patch) | |
tree | b64fa7dd82996af0c5c6a8780e08b1d101485c6f /org.eclipse.jgit.pgm | |
parent | 2fba1e65e1ce5070b56fe9ef3573a6bf7b5dcf3b (diff) | |
download | jgit-68ab451d3907e38f7c259ef52a9c3c6a6ee42ead.tar.gz jgit-68ab451d3907e38f7c259ef52a9c3c6a6ee42ead.zip |
ProgressMonitor: Refactor to use background alarms
Instead of polling the system clock on every update(1) method call,
use a scheduled executor to toggle a volatile once per second until
the task is done. Check the volatile on each update(int), looking
to see if output should occur.
This limits progress output to either once per 1% complete, or once
per second. To save time during update calls the timer isn't reset
during each 1% of output, which means we may see one unnecessary
output trigger if at least 1% completed during the one second of the
alarm time.
Change-Id: I8fdd7e31c37bef39a5d1b3da7105da0ef879eb84
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Diffstat (limited to 'org.eclipse.jgit.pgm')
-rw-r--r-- | org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Diff.java | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Diff.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Diff.java index 506031713a..5cc058950c 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Diff.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Diff.java @@ -52,6 +52,7 @@ import java.io.BufferedOutputStream; import java.io.PrintWriter; import java.text.MessageFormat; import java.util.List; +import java.util.concurrent.TimeUnit; import org.eclipse.jgit.diff.DiffAlgorithm; import org.eclipse.jgit.diff.DiffAlgorithm.SupportedAlgorithm; @@ -189,7 +190,9 @@ class Diff extends TextBuiltin { } else if (newTree == null) newTree = new FileTreeIterator(db); - diffFmt.setProgressMonitor(new TextProgressMonitor()); + TextProgressMonitor pm = new TextProgressMonitor(); + pm.setDelayStart(2, TimeUnit.SECONDS); + diffFmt.setProgressMonitor(pm); diffFmt.setPathFilter(pathFilter); if (detectRenames != null) diffFmt.setDetectRenames(detectRenames.booleanValue()); |