Package com.chemaxon.calculations.common
Class ProgressObservers
- java.lang.Object
-
- com.chemaxon.calculations.common.ProgressObservers
-
@Beta @PublicAPI public final class ProgressObservers extends Object
Utility functions for the creation of ProgressObservers.Please note that this class is marked with @Beta annotation, so it can be subject of incompatible changes or removal in any of the later releases.
-
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static CancelObserver
anyCancelled(CancelObserver... cancelObservers)
Returns a cancel observer which cancels when any of the specified observer is cancelled.static SubProgressObserver
createForgivingNullObserver()
Deprecated.UsenullProgressObserver()
instead.static CancelObserver
createNoCancelObserver()
Deprecated.UsenoCanceller()
static SubProgressObserver
createNullObserver(String taskName)
Deprecated.static SubProgressObserver
createStrictNullObserver()
Returns a SubProgressObserver which ignores observed data.static CancelObserver
noCanceller()
Returns a cancel observer which wont cancel execution.static SubProgressObserver
nullProgressObserver()
Returns a forgiving observer which wont enforce API contracts.static SubProgressObserver
nullProgressObserver(CancelObserver canceller)
Returns a forgiving cancellable observer which wont enforce API contracts.static CancelObserver
orTimeout(CancelObserver cancelObserver, long timeoutInSeconds)
Returns a cancel observer which cancels when a passed observer is cancelled or a timeout occurred.static CancelObserver
timeoutCanceller(long timeoutInSeconds)
Returns a cancel observer which cancels after a specified timeout.
-
-
-
Method Detail
-
createStrictNullObserver
public static SubProgressObserver createStrictNullObserver()
Returns a SubProgressObserver which ignores observed data.API contract is still enforced, eg.
IllegalStateException
is thrown on API contract breaches from the observed code.- Returns:
- A ProgressObserver with no query functionality.
-
createNullObserver
@Deprecated public static SubProgressObserver createNullObserver(String taskName)
Deprecated.Returns a SubProgressObserver which ignores observed data.API contract is still enforced, eg.
IllegalStateException
is thrown on API contract breaches from the observed code.- Parameters:
taskName
- Name of observed subtask- Returns:
- A ProgressObserver with no query functionality.
-
noCanceller
public static CancelObserver noCanceller()
Returns a cancel observer which wont cancel execution.- Returns:
- A canceller which wont cancel
-
timeoutCanceller
public static CancelObserver timeoutCanceller(long timeoutInSeconds)
Returns a cancel observer which cancels after a specified timeout. This method returns a naive observer which checksSystem.currentTimeMillis()
upon every invocation of itsCancelObserver.isCancelled()
method.- Parameters:
timeoutInSeconds
- Timeout in seconds. Use0
for no timeout.- Returns:
- Canceller which cancel after a specified amount of time or a
noCanceller()
when0
timeout is specified
-
anyCancelled
public static CancelObserver anyCancelled(CancelObserver... cancelObservers)
Returns a cancel observer which cancels when any of the specified observer is cancelled.- Parameters:
cancelObservers
- Observers to watch. Note thatnull
is accepted- Returns:
- Canceller which cancel when any of the passed non-null observers cancelled
-
orTimeout
public static CancelObserver orTimeout(CancelObserver cancelObserver, long timeoutInSeconds)
Returns a cancel observer which cancels when a passed observer is cancelled or a timeout occurred.- Parameters:
cancelObserver
- Base observer, can benull
timeoutInSeconds
- Timeout in seconds; use0
for no timeout- Returns:
- Canceller
-
createNoCancelObserver
@Deprecated public static CancelObserver createNoCancelObserver()
Deprecated.UsenoCanceller()
Returns a cancel observer which wont cancel execution.- Returns:
- A Canceller which wont cancel
-
nullProgressObserver
public static SubProgressObserver nullProgressObserver()
Returns a forgiving observer which wont enforce API contracts.- Returns:
- A
SubProgressObserver
which wont enforce API contracts and wont cancel
-
createForgivingNullObserver
@Deprecated public static SubProgressObserver createForgivingNullObserver()
Deprecated.UsenullProgressObserver()
instead.Returns a forgiving observer which wont enforce API contracts.- Returns:
- A
SubProgressObserver
which wont enforce API contracts and wont cancel
-
nullProgressObserver
public static SubProgressObserver nullProgressObserver(CancelObserver canceller)
Returns a forgiving cancellable observer which wont enforce API contracts.Note that current implementation polls cancelling upon method calls. If an observed code expects cancelling only through listener callbacks and wont call other methods (progress update) cancel event wont be generated.
- Parameters:
canceller
- Underlying canceller polled at every operation- Returns:
- A
SubProgressObserver
which wont enforce API contracts and propagates cancellinkg
-
-