public class NoOverflowAutoDoneProgressObserver extends Object implements ProgressObserver
worked(long)
calls reach totalWork,
but keeps accumulatedWork at totalWork's value in this case.Constructor and Description |
---|
NoOverflowAutoDoneProgressObserver(ProgressObserver delegate) |
Modifier and Type | Method and Description |
---|---|
void |
done()
Notifies that the represented task is done and no further work will be done.
|
boolean |
isCancelled()
Returns whether cancellation of current operation has been requested.
|
SubProgressObserver |
subTask(String name,
long work)
Follow the processing of a specific amount of work units by a separate observer.
|
void |
switchToDeterminate(long totalWork)
Notifies that the remaining amount of work units to complete this task is known.
|
void |
worked(long work)
Notifies that a given number of work units has been completed.
|
void |
workUnit(String workUnit)
Notifies the measure unit of work (such as 'pc', 'file', 'percent', etc).
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
close
public NoOverflowAutoDoneProgressObserver(ProgressObserver delegate)
public boolean isCancelled()
CancelObserver
Long running/memory intensive operations should poll to see if cancelation has been requested. Since time-out based cancelations might be implemented polling should not be done too often.
It is expected that implementations wont return false
after a true
value returned.
It is also expected that implementations tolerate multiple calls regardless of the cancallation state.
Please note that test cases might check for too frequent invocations, so the propagation of any
AssertionError
thrown by this method should not be obstructed.
It is usually expected that the cancelled task should throw
CancellationException
and this behavior should be documented in their APIdocs.
isCancelled
in interface CancelObserver
public void switchToDeterminate(long totalWork)
ProgressObserver
switchToDeterminate
in interface ProgressObserver
totalWork
- The total amount of work represented by this task.public void workUnit(String workUnit)
ProgressObserver
workUnit
in interface ProgressObserver
workUnit
- the measure unit of work.public void worked(long work)
done()
will be explicitly called. worked
in interface ProgressObserver
work
- Amount of work reportedIllegalStateException
- When done()
is already invoked.IllegalArgumentException
- When work
is zero or negativepublic void done()
ProgressObserver
NOTE: Cancellation has no effect to the progress state, so this method must be invoked when done, either due normal completion; cancellation or error
done
in interface ProgressObserver
public SubProgressObserver subTask(String name, long work)
ProgressObserver
The given amount of work on the level of the current observer is considered completed upon
ProgressObserver.done()
called on the returned subtask's observer.
Cancel propagation is expected to be transparent.
The strict contract regarding the state when ProgressObserver.worked(long)
can be called is relaxed in
the context of subtask observers: implicitly logging work on the upper level by calling
ProgressObserver.done()
on the subtask level after the upper level is closed will no cause
problem on either level.
subTask
in interface ProgressObserver
name
- Name of the represented sub task (for example to display)work
- A non-negative number of work units considered to be completed upon finishing
the associated subtask.