org.eclipse.jgit.lib.ProgressMonitor to
make it thread safe.
Updates to the underlying ProgressMonitor are made only from the thread that
allocated this wrapper. Callers are responsible for ensuring the allocating
thread uses pollForUpdates() or waitForCompletion() to
update the underlying ProgressMonitor.
Only update(int), isCancelled(), and endWorker()
may be invoked from a worker thread. All other methods of the ProgressMonitor
interface can only be called from the thread that allocates this wrapper.
| Modifier and Type | Field and Description |
|---|---|
| private final ReentrantLock | |
| private final Thread | |
| private final AtomicInteger | |
| private final ProgressMonitor | |
| private final Semaphore | |
| private final AtomicInteger |
| Access | Constructor and Description |
|---|---|
| public | ThreadSafeProgressMonitor(ProgressMonitor
the underlying monitor to receive events. pm)Wrap a ProgressMonitor to be thread safe. |
| Modifier and Type | Method and Description |
|---|---|
| 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;
totalWork)UNKNOWN if it cannot be predicted in advance.Implements org. Begin processing a single task. |
| private void | |
| public void | endTask()
Implements org. Finish the current task, so the next can begin. |
| public void | |
| public boolean | isCancelled()
Implements org. Check for user task cancellation. |
| private boolean | |
| public void | |
| public void | showDuration(boolean
whether to show elapsed time per task enabled)Implements org. Set whether the monitor should show elapsed time per task |
| public void | start(int
the total number of tasks the caller will need to complete
their processing. totalTasks)Implements org. Advise the monitor of the total number of subtasks. |
| public void | |
| public void | startWorkers(int
the number of worker threads that are starting. count)Notify the monitor of workers starting. |
| public void | update(int
the number of work units completed since the last call. completed)Implements org. Denote that some work units have been completed. |
| public void |
| lock | back to summary |
|---|---|
| private final ReentrantLock lock | |
| mainThread | back to summary |
|---|---|
| private final Thread mainThread | |
| pendingUpdates | back to summary |
|---|---|
| private final AtomicInteger pendingUpdates | |
| pm | back to summary |
|---|---|
| private final ProgressMonitor pm | |
| process | back to summary |
|---|---|
| private final Semaphore process | |
| workers | back to summary |
|---|---|
| private final AtomicInteger workers | |
| ThreadSafeProgressMonitor | back to summary |
|---|---|
| public ThreadSafeProgressMonitor(ProgressMonitor pm) Wrap a ProgressMonitor to be thread safe.
| |
| beginTask | back to summary |
|---|---|
| public void beginTask(String title, int totalWork) Implements org. Doc from org. Begin processing a single task.
| |
| doUpdates | back to summary |
|---|---|
| private void doUpdates() | |
| endTask | back to summary |
|---|---|
| public void endTask() Implements org. Doc from org. Finish the current task, so the next can begin.
| |
| endWorker | back to summary |
|---|---|
| public void endWorker() Notify the monitor a worker is finished. | |
| isCancelled | back to summary |
|---|---|
| public boolean isCancelled() Implements org. Doc from org. Check for user task cancellation.
| |
| isMainThread | back to summary |
|---|---|
| private boolean isMainThread() | |
| pollForUpdates | back to summary |
|---|---|
| public void pollForUpdates() Non-blocking poll for pending updates. This method can only be invoked by the same thread that allocated this ThreadSafeProgressMonior. | |
| showDuration | back to summary |
|---|---|
| public void showDuration(boolean enabled) Implements org. Doc from org. Set whether the monitor should show elapsed time per task
| |
| start | back to summary |
|---|---|
| public void start(int totalTasks) Implements org. Doc from org. Advise the monitor of the total number of subtasks. This should be invoked at most once per progress monitor interface.
| |
| startWorker | back to summary |
|---|---|
| public void startWorker() Notify the monitor a worker is starting. | |
| startWorkers | back to summary |
|---|---|
| public void startWorkers(int count) Notify the monitor of workers starting.
| |
| update | back to summary |
|---|---|
| public void update(int completed) Implements org. Doc from org. 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
| |
| waitForCompletion | back to summary |
|---|---|
| public void waitForCompletion() throws InterruptedException Process pending updates and wait for workers to finish. This method can only be invoked by the same thread that allocated this ThreadSafeProgressMonior.
| |