Top Description Inners Fields Constructors Methods
org.eclipse.jgit.lib

public abstract Class BatchingProgressMonitor

extends Object
implements ProgressMonitor
Class Inheritance
All Implemented Interfaces
org.eclipse.jgit.lib.ProgressMonitor
Known Direct Subclasses
org.eclipse.jgit.lib.TextProgressMonitor, org.eclipse.jgit.transport.SideBandProgressMonitor
Imports
java.time.Duration, .Instant, java.util.concurrent.Future, .TimeUnit, org.eclipse.jgit.lib.internal.WorkQueue, org.eclipse.jgit.util.SystemReader

ProgressMonitor that batches update events.

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class

Field Summary

Modifier and TypeField and Description
private long
private TimeUnit
private static boolean
private Boolean
private BatchingProgressMonitor.Task

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
protected void
appendDuration(StringBuilder
StringBuilder to append the formatted duration to
s
,
Duration
duration to format
duration
)

Append formatted duration if system property or environment variable GIT_TRACE_PERFORMANCE is set to "true".

public void
beginTask(String
title to describe the task. Callers should publish these as stable string constants that implementations could match against for translation support.
title
,
int
total number of work units the application will perform; UNKNOWN if it cannot be predicted in advance.
work
)

Implements org.eclipse.jgit.lib.ProgressMonitor.beginTask.

Begin processing a single task.

public void
endTask()

Implements org.eclipse.jgit.lib.ProgressMonitor.endTask.

Finish the current task, so the next can begin.

public boolean
isCancelled()

Implements org.eclipse.jgit.lib.ProgressMonitor.isCancelled.

Check for user task cancellation.

protected abstract void
onEndTask(String
name of the task.
taskName
,
int
total number of units processed.
workCurr
,
Duration
how long this task runs
duration
)

Finish the progress monitor when the total wasn't known in advance.

protected abstract void
onEndTask(String
name of the task.
taskName
,
int
total number of units processed.
workCurr
,
int
estimated number of units to process.
workTotal
,
int
workCurr * 100 / workTotal.
percentDone
,
Duration
duration of the task
duration
)

Finish the progress monitor when the total is known in advance.

protected abstract void
onUpdate(String
name of the task.
taskName
,
int
number of units already completed.
workCurr
,
Duration
how long this task runs
duration
)

Update the progress monitor if the total work isn't known,

protected abstract void
onUpdate(String
name of the task.
taskName
,
int
number of units already completed.
workCurr
,
int
estimated number of units to process.
workTotal
,
int
workCurr * 100 / workTotal.
percentDone
,
Duration
how long this task runs
duration
)

Update the progress monitor when the total is known in advance.

public void
setDelayStart(long
how long to wait before output. If 0 output begins on the first update(int) call.
time
,
TimeUnit
time unit of time.
unit
)

Set an optional delay before the first output.

public void
showDuration(boolean
whether to show elapsed time per task
enabled
)

Implements org.eclipse.jgit.lib.ProgressMonitor.showDuration.

Set whether the monitor should show elapsed time per task

private boolean
public void
start(int
the total number of tasks the caller will need to complete their processing.
totalTasks
)

Implements org.eclipse.jgit.lib.ProgressMonitor.start.

Advise the monitor of the total number of subtasks.

public void
update(int
the number of work units completed since the last call.
completed
)

Implements org.eclipse.jgit.lib.ProgressMonitor.update.

Denote that some work units have been completed.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

delayStartTimeback to summary
private long delayStartTime
delayStartUnitback to summary
private TimeUnit delayStartUnit
performanceTraceback to summary
private static boolean performanceTrace
showDurationback to summary
private Boolean showDuration
taskback to summary
private BatchingProgressMonitor.Task task

Constructor Detail

BatchingProgressMonitorback to summary
public BatchingProgressMonitor()

Method Detail

appendDurationback to summary
protected void appendDuration(StringBuilder s, Duration duration)

Append formatted duration if system property or environment variable GIT_TRACE_PERFORMANCE is set to "true". If both are defined the system property takes precedence.

Parameters
s:StringBuilder

StringBuilder to append the formatted duration to

duration:Duration

duration to format

Annotations
@SuppressWarnings:boxing, nls
Since
6.5
beginTaskback to summary
public void beginTask(String title, int work)

Implements org.eclipse.jgit.lib.ProgressMonitor.beginTask.

Doc from org.eclipse.jgit.lib.ProgressMonitor.beginTask.

Begin processing a single task.

Parameters
title:String

title to describe the task. Callers should publish these as stable string constants that implementations could match against for translation support.

work:int

total number of work units the application will perform; UNKNOWN if it cannot be predicted in advance.

Annotations
@Override
endTaskback to summary
public void endTask()

Implements org.eclipse.jgit.lib.ProgressMonitor.endTask.

Doc from org.eclipse.jgit.lib.ProgressMonitor.endTask.

Finish the current task, so the next can begin.

Annotations
@Override
isCancelledback to summary
public boolean isCancelled()

Implements org.eclipse.jgit.lib.ProgressMonitor.isCancelled.

Doc from org.eclipse.jgit.lib.ProgressMonitor.isCancelled.

Check for user task cancellation.

Returns:boolean

true if the user asked the process to stop working.

Annotations
@Override
onEndTaskback to summary
protected abstract void onEndTask(String taskName, int workCurr, Duration duration)

Finish the progress monitor when the total wasn't known in advance.

Parameters
taskName:String

name of the task.

workCurr:int

total number of units processed.

duration:Duration

how long this task runs

Since
6.5
onEndTaskback to summary
protected abstract void onEndTask(String taskName, int workCurr, int workTotal, int percentDone, Duration duration)

Finish the progress monitor when the total is known in advance.

Parameters
taskName:String

name of the task.

workCurr:int

total number of units processed.

workTotal:int

estimated number of units to process.

percentDone:int

workCurr * 100 / workTotal.

duration:Duration

duration of the task

Since
6.5
onUpdateback to summary
protected abstract void onUpdate(String taskName, int workCurr, Duration duration)

Update the progress monitor if the total work isn't known,

Parameters
taskName:String

name of the task.

workCurr:int

number of units already completed.

duration:Duration

how long this task runs

Since
6.5
onUpdateback to summary
protected abstract void onUpdate(String taskName, int workCurr, int workTotal, int percentDone, Duration duration)

Update the progress monitor when the total is known in advance.

Parameters
taskName:String

name of the task.

workCurr:int

number of units already completed.

workTotal:int

estimated number of units to process.

percentDone:int

workCurr * 100 / workTotal.

duration:Duration

how long this task runs

Since
6.5
setDelayStartback to summary
public void setDelayStart(long time, TimeUnit unit)

Set an optional delay before the first output.

Parameters
time:long

how long to wait before output. If 0 output begins on the first update(int) call.

unit:TimeUnit

time unit of time.

showDurationback to summary
public void showDuration(boolean enabled)

Implements org.eclipse.jgit.lib.ProgressMonitor.showDuration.

Doc from org.eclipse.jgit.lib.ProgressMonitor.showDuration.

Set whether the monitor should show elapsed time per task

Parameters
enabled:boolean

whether to show elapsed time per task

Annotations
@Override
showDurationback to summary
private boolean showDuration()
startback to summary
public void start(int totalTasks)

Implements org.eclipse.jgit.lib.ProgressMonitor.start.

Doc from org.eclipse.jgit.lib.ProgressMonitor.start.

Advise the monitor of the total number of subtasks.

This should be invoked at most once per progress monitor interface.

Parameters
totalTasks:int

the total number of tasks the caller will need to complete their processing.

Annotations
@Override
updateback to summary
public void update(int completed)

Implements org.eclipse.jgit.lib.ProgressMonitor.update.

Doc from org.eclipse.jgit.lib.ProgressMonitor.update.

Denote that some work units have been completed.

This is an incremental update; if invoked once per work unit the correct value for our argument is 1, to indicate a single unit of work has been finished by the caller.

Parameters
completed:int

the number of work units completed since the last call.

Annotations
@Override
org.eclipse.jgit.lib back to summary

private Class BatchingProgressMonitor.Task

extends Object
implements Runnable
Class Inheritance
All Implemented Interfaces
java.lang.Runnable

Field Summary

Modifier and TypeField and Description
private volatile boolean
display

True when timer expires and output should occur on next update.

private int
lastPercent

Percentage of totalWork that is done.

private int
lastWork

Number of work units already completed.

private boolean
output

True if the task has displayed anything.

private final Instant
private final String
taskName

Title of the current task.

private Future<?>
timerFuture

Scheduled timer, supporting cancellation if task ends early.

private final int
totalWork

Number of work units, or ProgressMonitor#UNKNOWN.

Constructor Summary

AccessConstructor and Description
pack-priv
Task(String taskName, int totalWork)

Method Summary

Modifier and TypeMethod and Description
pack-priv void
delay(long time, TimeUnit unit)

private Duration
pack-priv void
private void
public void
run()

Implements java.lang.Runnable.run.

Runs this operation.

pack-priv void
update(BatchingProgressMonitor pm, int completed)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

displayback to summary
private volatile boolean display

True when timer expires and output should occur on next update.

lastPercentback to summary
private int lastPercent

Percentage of totalWork that is done.

lastWorkback to summary
private int lastWork

Number of work units already completed.

outputback to summary
private boolean output

True if the task has displayed anything.

startTimeback to summary
private final Instant startTime
taskNameback to summary
private final String taskName

Title of the current task.

timerFutureback to summary
private Future<?> timerFuture

Scheduled timer, supporting cancellation if task ends early.

totalWorkback to summary
private final int totalWork

Number of work units, or ProgressMonitor#UNKNOWN.

Constructor Detail

Taskback to summary
pack-priv Task(String taskName, int totalWork)

Method Detail

delayback to summary
pack-priv void delay(long time, TimeUnit unit)
elapsedTimeback to summary
private Duration elapsedTime()
endback to summary
pack-priv void end(BatchingProgressMonitor pm)
restartTimerback to summary
private void restartTimer()
runback to summary
public void run()

Implements java.lang.Runnable.run.

Doc from java.lang.Runnable.run.

Runs this operation.

Annotations
@Override
updateback to summary
pack-priv void update(BatchingProgressMonitor pm, int completed)